美文网首页
46、初识搜索引擎_常用的各种query搜索语法

46、初识搜索引擎_常用的各种query搜索语法

作者: 拉提娜的爸爸 | 来源:发表于2020-01-08 16:19 被阅读0次

1、match all 查询全部

GET /_search
{
    "query": {
        "match_all": {}
    }
}

2、match 指定条件查询

GET /_search
{
  "query": {
    "match": {
      "test_content": "automatic"
    }
  }
}

3、multi match 同一field多条件查询

query:要查询的内容
fields:要查询的field字段

GET /_search
{
  "query": {
    "multi_match": {
      "query": "client",
      "fields": ["test_field1","test_field2"]
    }
  }
}

4、range query 对比查询

查询年龄大于30的数据

GET /company/employee/_search
{
  "query": {
    "range": {
      "age": {
        "gte": 30
      }
    }
  }
}

5、term query 不会对查询条件进行分词

如果查询条件未分词,但是查询的数据field是分词的,会有可能查询不到结果

GET /test_index/test_type/_search 
{
  "query": {
    "term": {
      "test_field": "test client 2"
    }
  }
}

6、terms query 查询多个内容,并且不分词

GET /_search
{
    "query": { "terms": { "tag": [ "search", "full_text", "nosql" ] }}
}

7、exist query(2.x中的查询,现在已经不提供了)

相关文章

网友评论

      本文标题:46、初识搜索引擎_常用的各种query搜索语法

      本文链接:https://www.haomeiwen.com/subject/fejsactx.html