zoukankan      html  css  js  c++  java
  • 50.常用的query查询方式

    主要知识点

    • 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中的查询,现在已经不提供了)

  • 相关阅读:
    CSS3实现轮播切换效果
    angularjs directive
    angularjs 迭代器
    anjularjs 路由
    sublime text3 快捷键设置
    如何使用git 跟进项目进程
    hdu 4842(NOIP 2005 过河)之 动态规划(距离压缩)
    叠箱子问题 之 动态规划
    华为oj 之 蜂窝小区最短距离
    华为oj 之 整数分隔
  • 原文地址:https://www.cnblogs.com/liuqianli/p/8471677.html
Copyright © 2011-2022 走看看