码迷,mamicode.com
首页 > 其他好文 > 详细

50.常用的query查询方式

时间:2018-02-26 11:43:16      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:bsp   post   match   text   elastics   mon   style   china   nbsp   

主要知识点

  • match all
  • match
  • multi match
  • range query
  • term query
  • terms query
  • exist query

   

   

1match all

查询所有

GET /_search

{

"query": {

"match_all": {}

}

}

示例:

GET /company/employee/_search

{

"query": {

"match_all": {}

}

}

   

2match

GET /_search

{

"query": { "match": { "title": "my elasticsearch article" }}

}

示例:

GET /company/employee/_search

{

"query": {

"match": {

"age": "27"

}

}

}

   

3multi match

GET /test_index/test_type/_search

{

"query": {

"multi_match": {

"query": "test",

"fields": ["test_field", "test_field1"]

}

}

}

示例:

GET /company/employee/_search

{

"query": {

"multi_match": {

"query": "china",

"fields": ["address.city","address.country","address.province"]

}

}

}

   

4range query

GET /company/employee/_search

{

"query": {

"range": {

"age": {

"gte": 30

}

}

}

}

示例:

GET /company/employee/_search

{

"query": {

"range": {

"age": {

"gte": 30

}

}

}

}

   

5term query

不分词,必须精确匹配

GET /test_index/test_type/_search

{

"query": {

"term": {

"test_field": "test hello"

}

}

}

   

6terms query

不分词,必须精确匹配

GET /_search

{

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

}

   

7exist query

2.x中的查询,现在已经不提供了)

50.常用的query查询方式

标签:bsp   post   match   text   elastics   mon   style   china   nbsp   

原文地址:https://www.cnblogs.com/liuqianli/p/8471677.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!