ES如何使用requestbody进行查询

GET kibana_sample_data_ecommerce/_search
{
  "_source": ["order_date","day_of_week"], 
  "sort":[{"order_date": "desc"}],
  "from":"10",
  "size": 2,
  "query": {
    "match_all": {}
  }
}

如果有一个字段是数组类型

GET kibana_sample_data_ecommerce/_search
{
  "query": {
    "match": {
      "products.base_price": "90"
    }
    
  }
}
GET kibana_sample_data_ecommerce/_search
{
  "query": {
    "match": {
      "customer_full_name": {
        "query": "Eddie Perry",
        "operator": "and"
      }
    }
    
  }
}

----------------------MAPPING-----------------------------

1 空值查询

PUT null_value_test
{
  "mappings" : {
      "properties" : {
        "first_name" : {
          "type" : "text"
          
        },
        "last_name" : {
          "type" : "text"
 
        },
        "mobile" : {
          "type" : "keyword",
          "null_value": "NULLNULL"
        }
      }
    }
}

2 copy to

PUT copy_to_test
{
  "mappings" : {
      "properties" : {
        "first_name" : {
          "type" : "text",
          "copy_to":"full_name"
        },
        "last_name" : {
          "type" : "text",
          "copy_to":"full_name"
        } 
      }
    }
}
PUT copy_to_test/_doc/1
{
  "first_name":"qi",
  "last_name":"hongfei"
}

PUT copy_to_test/_doc/2
{
  "first_name":"liu",
  "last_name":"yifei"
}
GET copy_to_test/_search
GET copy_to_test/_search?q=full_name:liu yifei

猜你喜欢

转载自blog.csdn.net/weixin_39394909/article/details/105331475