支持与或非的字符串检索 query_string

使用具有严格语法的解释器,根据提供的查询字符串返回文档。

curl -X GET "localhost:9200/_search?pretty" -H 'Content-Type: application/json' -d'
{
  "query": {
    "query_string": {
      "query": "(new york city) OR (big apple)",
      "default_field": "content"
    }
  }
}
'

运行该搜索时,query_string查询分为(new york city) OR (big apple)两部分:new york citybig apple该 字段的分析器在返回匹配的文档之前,将每个部分独立地转换为令牌。由于查询语法不使用空格作为运算符,new york city因此按原样传递给分析器。

default_field

(可选,字符串)如果查询字符串中未提供任何字段,则为您要搜索的默认字段。

默认为index.query.default_field索引设置,其默认值为**值提取符合条件查询的所有字段,并过滤元数据字段。如果未prefix指定,则合并所有提取的字段以构建查询

allow_leading_wildcard

(可选,布尔值)如果为true则允许使用通配符*?作为查询字符串的第一个字符。默认为true

 

 

https://www.elastic.co/guide/en/elasticsearch/reference/7.11/query-dsl-query-string-query.html#query-string-syntax

posted @ 2021-03-08 14:57  薄荷味日记  阅读(235)  评论(0编辑  收藏  举报