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

ELK学习总结(3-2)elk的filter查询过滤

时间:2017-03-31 17:01:33      阅读:127      评论:0      收藏:0      [点我收藏+]

标签:mis   filter   ring   term   should   index   --   没有   str   

和一般查询比较,filter查询能够缓存数据,应该尽可能使用

 

建立测试数据

查看测试数据

 

1、filtered查询

GET /store/products/_search

{

      "query":{

           "filtered":{

               "query": {

                      "match_all":{}               

               },

               filter:{

                      "terms":{

                            "price":[10,20] 

                      }

               } 

          }

      }

}

 

## 调用没有得到结果? 因为mapping没有指定not_analyzed

GET /store/products/_search

{

      "query":{

           "filtered":{

               "query": {

                      "match_all":{}               

               },

               filter:{

                      "term":{

                            "productID":"QW123"

                      }

               } 

          }

      }

}

 

GET /_analyze?text=QW123

--发现分析结果呈小写qw123

 

GET /store/_mapping

DELETE /store

 

##解决办法:重新建立一个映射,让productID处于not_analyzed模式

PUT /store

{

      "mappings":{

           "products":{

               "properties": {

                      "productID":{

                           “type”:“string”,

                           “index”:“not_analyzed”

                      }               

               } 

          }

      }

}

 

2、bool过滤查询,可以实现组合过滤查询 

"bool":{

     "must":[],

     "should":[], 可以满足,也可以不满足

     "must_not":[]

}

 

GET /store/products/_search

{

      "query":{

           "filtered":{

               "filter": {

                      "bool":{

                          "should":[

                                {"term":{"price":20}},

                                {"term":{"productID":"SD12342"}}

                          ],

                          "must_not":[

                                {"term":{"price":30}}

                          ]

                      }                              

               } 

          }

      }

}

 

3、嵌套查询 and or not查询

    and  并且

    or    或者

    not  不是

 

4、range过滤查询

     gt:>

     lt:<

     gte: >=

     lte : <=

 

5、过滤空和非空

     exists

     missing

 

6、cache缓存

     

 

ELK学习总结(3-2)elk的filter查询过滤

标签:mis   filter   ring   term   should   index   --   没有   str   

原文地址:http://www.cnblogs.com/lexiaofei/p/6651828.html

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