2017-12-21 20 views
0

私はElasticSearchに1000台の車のレコードを挿入しました。私は次のことを実行するとElasticSearch - 検索フィルターが機能しない

{ "index" : { "_index" : "car", "_type" : "car", "_id" : "1" } } 
{"id":1,"car_make":"Chevrolet","car_model":"Express","car_year":2012,"car_color":"Goldenrod","made_in":"Indonesia"} 
{ "index" : { "_index" : "car", "_type" : "car", "_id" : "2" } } 
{"id":2,"car_make":"BMW","car_model":"Z8","car_year":2002,"car_color":"Fuscia","made_in":"China"} 
{ "index" : { "_index" : "car", "_type" : "car", "_id" : "3" } } 
... 
... 
... 

、私は戻って、いくつかの結果を得るために期待していたが、今はゼロの結果を取得しています。

>> curl -XGET 'localhost:9200/car/car/_search?pretty' -H 'Content-Type: application/json' -d' 
> { 
> "query": { 
>  "bool": { 
>  "must": { "match_all": {} }, 
>  "filter": { 
>   "terms": { 
>   "car_make": ["BMW","Lexus"] 
>   } 
>  } 
>  } 
> } 
> } 
> 
> ' 
{ 
    "took" : 18, 
    "timed_out" : false, 
    "_shards" : { 
    "total" : 5, 
    "successful" : 5, 
    "failed" : 0 
    }, 
    "hits" : { 
    "total" : 0, 
    "max_score" : null, 
    "hits" : [ ] 
    } 
} 
+0

をあなたはcar_make' 'のあなたのマッピングを共有しませんか? – sunkuet02

+0

インデックスのマッピングを共有できますか? –

答えて

0

car(インデックス/タイプ)のカスタムマッピングを作成していますか?そうでない場合は、textkeywordのフィールドタイプがデフォルト設定されます(es 5.xを使用すると正確なバージョンが記憶されない場合)。

場合その場合は、試すことができます:

{ 
    "query": { 
    "bool": { 
     "filter": { 
     "terms": { 
      "car_make.keyword": ["BMW","Lexus"] 
     } 
     } 
    } 
    } 
} 
関連する問題