介绍
官方文档:https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html
返回与提供的参数(文本、数字、日期或布尔值)匹配的文档。在匹配之前对提供的参数文本进行分词。
match查询是执行全文搜索的标准查询,包括模糊匹配选项。
例子:
GET /_search
{
"query": {
"match": {
"message": {
"query": "this is a test"
}
}
}
}
match的顶级参数field
<field> (Required, object) 你希望查询的字段.
field的参数(常用,不全)
参数名 | 描述 |
---|---|
query | (必需)您希望在提供的<字段>中查找的文本、数字、布尔值或日期。 |
analyzer | (可选,字符串) 参数分析器。默认为对应<field>索引时指定的分析器。如果没有映射分析器,则使用索引的默认分析器。 |
operator | (可选,字符串)用于解释查询值中的文本的布尔逻辑。有效值: OR (Default) 例如, 查询参数的值为 capital of Hungary将被解释为 (capital OR of OR Hungary)。上文说过,match的查询参数会被分词。 AND 例如, 查询参数的值为 capital of Hungary将被解释为 (capital AND of AND Hungary)。 |
minimum_should_match | (可选,字符串) 必须匹配返回文档的最小数。 |
match的简写
如果field的参数,只传一个query参数,则可以简化匹配查询语法。例如:
GET /_search
{
"query": {
"match": {
"message": "this is a test"
}
}
}