美文网首页
002 RequestBody查询

002 RequestBody查询

作者: zhu733756 | 来源:发表于2020-03-15 15:23 被阅读0次

#1 筛选字段查询,from开始,size返回的条数

GET kibana_sample_data_ecommerce/_search

{

  "query": {"match_all": {}},

  "_source": ["category","customer_first_name","currency","customer_id"],

  "from": 10,

  "size": 5,

  "profile": "true"

}

#2 按照日期降序

GET kibana_sample_data_ecommerce/_search

{

  "query": {"match_all": {}},

  "sort": [

    {

      "order_date": "desc"

    }

  ],

  "_source": ["category","customer_first_name","currency","customer_id","order_date"],

  "from": 10,

  "size": 5,

  "profile": "true"

}

#3 脚本字段

GET kibana_sample_data_ecommerce/_search

{

  "script_fields": {

    "new_field": {

      "script": {

        "lang": "painless",

        "source": "doc['_id'].value + '_hello'"

      }

    }

  },

  "query": {"match_all": {}}

}

# 4 match查询, 模糊查询

GET kibana_sample_data_ecommerce/_search

{

  "query": {

    "match": {

      "customer_first_name": "Rabbia Al"

    }

  },

  "profile": "true"

}

# results 394

GET kibana_sample_data_ecommerce/_search

{

  "query": {

    "match": {

      "customer_first_name": {

        "query": "Rabbia Al",

        "operator": "and"

      }

    }

  },

  "profile": "true"

}

# results 158

#5 match_phrase查询,可加入slop将query中的词扩展

GET kibana_sample_data_ecommerce/_search

{

  "query": {

    "match_phrase": {

      "customer_full_name": {

        "query": "Rabbia Baker",

        "slop": 1

      }

    }

  }

}

相关文章

网友评论

      本文标题:002 RequestBody查询

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