43.初識搜索引擎_常用的各種query搜索語法

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中的查詢,現在已經不提供了)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章