2016-04-27 20 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'を必要としています。また、上記の変更が機能するようにデータを再索引付けする必要があります。 –

+0

マッピングは次のようにする必要があります: '' fwot ':{ "type": "string"、 "index": "not_analyzed" } ' –

+0

small case.exampleのクエリ:" {"fwot" : "A6-APA"} } –

答えて

2

これが機能するには、fwotを"index": "not_analyzed"にする必要があります。また、上記の変更が機能するようにデータを再索引付けする必要があります。ここで

は、マッピングの変更といくつかのテストデータのためのコマンドの完全なリストがあります:それが機能するためには `「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

ありがとうAndrei、それは正常に働いた –

関連する問題