2016-04-27 101 views
1

我有一些文档和查询的映射再次术语确实失败。我不明白为什么:elasticsearch:术语查询失败

"mappings":{ 
    "timeslot":{ 
      "properties":{ 
       "FOB_IN":{ 
         "type":"long" 
       }, 
       "TRIGGER_CODE":{ 
         "type":"long" 
       }, 
       "FLIGHT_PHASE":{ 
         "type":"long" 
       }, 
       "REP16_TRIG":{ 
         "type":"long" 
       }, 
       "fwot":{ 
         "type":"string" 
       }, 
       "FOB_OUT":{ 
         "type":"long" 
       }, 
       "FP":{ 
         "type":"long" 
       }, 
       "FLTNB":{ 
         "type":"string" 
       }, 
       "Date":{ 
         "format":"strict_date_optional_time||epoch_millis", 
         "type":"date" 
       } 
      } 
    } 
} 

我可以做一个长期的查询对TRIGGER_CODE,例如,和

{ 
    "took": 1, 
    "timed_out": false, 
    "_shards": { 
     "total": 1, 
     "successful": 1, 
     "failed": 0 
    }, 
    "hits": { 
     "total": 5, 
     "max_score": 4.4446826, 
     "hits": [ 
     { 
      "_index": "merged-2016-04", 
      "_type": "timeslot", 
      "_id": "AVRS8VnirVLwfvMnwpXb", 
      "_score": 4.4446826, 
      "_source": { 
       "Date": "2016-04-03T08:42:44+0000", 
       "FLIGHT_PHASE": 20, 
       "TRIGGER_CODE": 4000, 
       "fwot": "A6-APA" 
      } 
     } 
     ] 
    } 
} 

现在同样对fwot不会失败它工作正常。怎么了?

GET merged-2016-04/_search?size=1 
{ 
    "query" : { 
     "term" : { "fwot": "A6-APA"} 
    } 
} 

{ 
    "took": 1, 
    "timed_out": false, 
    "_shards": { 
     "total": 1, 
     "successful": 1, 
     "failed": 0 
    }, 
    "hits": { 
     "total": 0, 
     "max_score": null, 
     "hits": [] 
    } 
} 
+0

你需要'fwot'是'“指数”:“not_analyzed”'对于工作。而且您需要重新编制数据以便上述更改生效。 –

+0

这意味着映射应该是这样的:''fwot“:{ ”type“:”string“,”index“:”not_analyzed“ }' –

+0

query case.example:”term“:{”fwot“ : “A6-APA”} } –

回答

2

你需要fwot是"index": "not_analyzed"该工作。而且您需要重新编制数据以便上述更改生效。

下面是映射的变化和一些测试数据的命令的完整列表:

PUT /merged-2016-04 
{ 
    "mappings": { 
    "timeslot": { 
     "properties": { 
     "FOB_IN": { 
      "type": "long" 
     }, 
     "TRIGGER_CODE": { 
      "type": "long" 
     }, 
     "FLIGHT_PHASE": { 
      "type": "long" 
     }, 
     "REP16_TRIG": { 
      "type": "long" 
     }, 
     "fwot": { 
      "type": "string", 
      "index": "not_analyzed" 
     }, 
     "FOB_OUT": { 
      "type": "long" 
     }, 
     "FP": { 
      "type": "long" 
     }, 
     "FLTNB": { 
      "type": "string" 
     }, 
     "Date": { 
      "format": "strict_date_optional_time||epoch_millis", 
      "type": "date" 
     } 
     } 
    } 
    } 
} 

POST /merged-2016-04/timeslot 
{ 
    "Date": "2016-04-03T08:42:44+0000", 
    "FLIGHT_PHASE": 20, 
    "TRIGGER_CODE": 4000, 
    "fwot": "A6-APA" 
} 

GET merged-2016-04/_search?size=1 
{ 
    "query": { 
    "term": { 
     "fwot": "A6-APA" 
    } 
    } 
} 
+0

谢谢安德烈,它工作得很好 –