《Elastic Stack 实战手册》——三、产品能力——3.4.入门篇——3.4.2.Elasticsearch基础应用——3.4.2.3.Search通过Kibana(16) https://developer.aliyun.com/article/1231053
Prefix 查询
返回在提供的字段中包含特定前缀的文档:
PUT my_shop_test { "settings": { "number_of_shards": 1, "number_of_replicas": 1 }, "mappings": { "properties": { "shopName":{ "type":"text" }, "shopCode":{ "type":"text" } } } } #添加测试数据 POST my_shop_test/_bulk {"index":{"_id":1}} {"shopName":"box","shopCode":"Smith"} {"index":{"_id":2}} {"shopName":"black","shopCode":"jack"} {"index":{"_id":3}} {"shopName":"fox","shopCode":"act"} {"index":{"_id":4}} {"shopName":"booex","shopCode":"act"} # GET /my_shop_test/_search { "query": { "prefix": { "shopName": { "value": "bo" } } } } #返回 "hits" : [ { "_index" : "my_shop_test", "_type" : "_doc", "_id" : "1", "_score" : 1.0, "_source" : { "shopName" : "box", "shopCode" : "Smith" } }, { "_index" : "my_shop_test", "_type" : "_doc", "_id" : "4", "_score" : 1.0, "_source" : { "shopName" : "booex", "shopCode" : "act" } } ]
Range 查询
Range 查询类似数据库中的大于、小于范围查询:
GET my_goods/_search { "query": { "range": { "publicPrice": { "gte": 2000, 351 > 三、产品能力 "lte": 8488 } } } }
l gt:大于
l gte:大于等于
l lt:小于
l lte:小于等于
Regexp 查询
正则表达式查询,查询店铺编码以 's' 开头,中间包括任何字符,以及长度且以'1'结尾的数据:
GET my_goods/_search { "query": { "regexp": { "shopCode": { "value": "s.*1", "flags": "ALL", "case_insensitive": true, "max_determinized_states": 10000, "rewrite": "constant_score" } } } }
《Elastic Stack 实战手册》——三、产品能力——3.4.入门篇——3.4.2.Elasticsearch基础应用——3.4.2.3.Search通过Kibana(18) https://developer.aliyun.com/article/1231051