elasticsearchindexingluceneelasticsearch-pluginsense

Elasticsearch Index type doesn't changed after updating status


I've made some _bulk insert successfully , now I'm trying to make query with date range and filter something like:

{
   "query": {
        "bool": {
            "must": [{
                "terms": {
                    "mt_id": [613]
                }
            },
            {
                "range": {
                    "time": {
                        "gt": 1470009600000,
                        "lt": 1470009600000
                    }
                }
            }]
        }
    }

Unfortunately I got no results , Now I noticed that the index mapping is created after bulk insert as following:

{
  "agg__ex_2016_8_3": {
    "mappings": {
      "player": {
        "properties": {
          "adLoad": {
            "type": "long"
          },
         "mt_id": {
           "type": "long"
          },
          "time": {
            "type": "string"
          }
        }
      },

As a solution I tried to change the index mapping with:

PUT /agg__ex_2016_8_3/_mapping/player
{
  "properties" : {
    "mt_id" : {
      "type" :    "long",
      "index":    "not_analyzed"
    }
  }
}

got

{
  "acknowledged": true
}

and PUT /agg__ex_2016_8_3/_mapping/player

{
  "properties" : {
    "time" : {
      "type" :    "date",
     "format" : "yyyy/MM/dd HH:mm:ss"
    }
  }
}

got:

{
   "error": {
      "root_cause": [
         {
            "type": "remote_transport_exception",
            "reason": "[vj_es_c1-esc13][10.132.69.145:9300][indices:admin/mapping/put]"
         }
      ],
      "type": "illegal_argument_exception",
      "reason": "mapper [time] of different type, current_type [string], merged_type [date]"
   },
   "status": 400
}

but nothing happened , and still doesn't get any results.

What i'm doing wrong ? ( I must work with http , not using curl)

Thanks!!


Solution

  • Try this:

    # 1. delete index
    DELETE agg__ex_2016_8_3
    
    # 2. recreate it with the proper mapping
    PUT agg__ex_2016_8_3
    {
      "mappings": {
        "player": {
          "properties": {
            "adLoad": {
              "type": "long"
            },
            "mt_id": {
              "type": "long"
            },
            "time": {
              "type": "date"
            }
          }
        }
      }
    }
    
    # 3. create doc
    PUT agg__ex_2016_8_3/player/104
    {
      "time": "1470009600000",
      "domain": "organisemyhouse.com",
      "master_domain": "613###organisemyhouse.com",
      "playerRequets": 4,
      "playerLoads": 0,
      "c_Id": 0,
      "cb_Id": 0,
      "mt_Id": 613
    }
    
    # 4. search
    POST agg__ex_2016_8_3/_search
    {
      "query": {
        "bool": {
          "must": [
            {
              "terms": {
                "mt_Id": [
                  613
                ]
              }
            },
            {
              "range": {
                "time": {
                  "gte": 1470009600000,
                  "lte": 1470009600000
                }
              }
            }
          ]
        }
      }
    }