2016-11-22 54 views

回答

1

您可以像任何其他字段一样进行搜索。

-bash-4.2$ curl 'localhost:9200/my_index/_search?pretty=true&q=passengers:John' 
{ 
    "took" : 4, 
    "timed_out" : false, 
    "_shards" : { 
    "total" : 5, 
    "successful" : 5, 
    "failed" : 0 
    }, 
    "hits" : { 
    "total" : 1, 
    "max_score" : 0.15342641, 
    "hits" : [ { 
     "_index" : "my_index", 
     "_type" : "cars", 
     "_id" : "1", 
     "_score" : 0.15342641, 
     "_source" : { 
     "color" : "red", 
     "passengers" : [ "John", "Annie", "William" ] 
     } 
    } ] 
    } 
} 
+0

,如果我想所有的约翰和安妮的? – awavi

+0

只是添加OR条款'q =乘客:约翰或乘客:安妮' –

0

尽管codegrep_admin的答案有用,但我一直在寻找可以更容易操作的东西。

我结束了使用bool这样的查询:

[GET] /my_index/cars/_search 

{ 
    "query": { 
    "bool": { 
     "must": [ 
      { "match": { "passengers": "John" }}, 
      { "match": { "passengers": "Annie" }} 
     ] 
    } 
} 
相关问题