短语检索 match_phrase query

match_phrase查询分析文本,并从分析的文本中创建短语查询

匹配查询的类型为布尔值。这意味着将对提供的文本进行分析,并且分析过程将从提供的文本中构造一个布尔查询。可以将operator参数设置为or或and来控制布尔子句(默认为or)。可以使用minimum_should_match参数设置要匹配的可选should子句的最小数量。

curl -X GET "localhost:9200/_search?pretty" -H 'Content-Type: application/json' -d'
{
  "query": {
    "match": {
      "message": {
        "query": "this is a test",
        "operator": "and"
      }
    }
  }
}
'

分析器可以设置为控制哪个分析器将对文本执行分析处理。 它默认为字段显式映射定义或默认搜索分析器

GET /_search
{
    "query": {
        "match_phrase" : {
            "message" : {
                "query" : "this is a test",
                "analyzer" : "my_analyzer"
            }
        }
    }
}

 

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