Elasticsearch REST API:仅按特定字段搜索

时间:2017-03-20 17:09:59

标签: elasticsearch

当我执行搜索时,我希望找到所有包含文字hello people的推文(或至少有一个这样的词)。

$ curl -XGET 'http://localhost:9200/_all/tweet/_search?q=text:hello people'

弹性仅对第一个单词应用字段(文本)过滤器,而在所有其他字段中搜索第二个单词。 显然,我的结果是回复,但也有很多我不期望的数据。

1 个答案:

答案 0 :(得分:4)

如下所述:https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax

您需要将查询字符串包装在()中,例如:

$ curl -XGET 'http://localhost:9200/_all/tweet/_search?q=text:(hello people)'