ES基础(十六)基于词项和基于全文的搜索
DELETE products PUT products { "settings": { "number_of_shards": 1 } } POST /products/_bulk { "index": { "_id": 1 }} { "productID" : "XHDK-A-1293-#fJ3","desc":"iPhone" } { "index": { "_id": 2 }} { "productID" : "KDKE-B-9947-#kL5","desc":"iPad" } { "index": { "_id": 3 }} { "productID" : "JODL-X-1937-#pV7","desc":"MBP" } GET /products POST /products/_search { "query": { "term": { "desc": { //"value": "iPhone" "value":"iphone" } } } } POST /products/_search { "query": { "term": { "desc.keyword": { //"value": "iPhone" //"value":"iphone" } } } } POST /products/_search { "query": { "term": { "productID": { "value": "XHDK-A-1293-#fJ3" } } } } POST /products/_search { //"explain": true, "query": { "term": { "productID.keyword": { "value": "XHDK-A-1293-#fJ3" } } } } POST /products/_search { "explain": true, "query": { "constant_score": { "filter": { "term": { "productID.keyword": "XHDK-A-1293-#fJ3" } } } } } #设置 position_increment_gap DELETE groups PUT groups { "mappings": { "properties": { "names":{ "type": "text", "position_increment_gap": 0 } } } } GET groups/_mapping POST groups/_doc { "names": [ "John Water", "Water Smith"] } POST groups/_search { "query": { "match_phrase": { "names": { "query": "Water Water", "slop": 100 } } } } POST groups/_search { "query": { "match_phrase": { "names": "Water Smith" } } }
本文来自博客园,作者:秋华,转载请注明原文链接:https://www.cnblogs.com/qiu-hua/p/14195179.html