基于 Term 的查询
Term 是表达语意的最?单位。搜索和利?统计语?模型进??然语?处理都需要处理 Term
特点
例子
创建index products_test
关于Term 查询的例子
POST /products_test/product/_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" }
POST /products_test/_search
{
"query": {
"term": {
"desc.keyword": {
//"value": "iPhone" 查不到结果
//"value":"iphone" 可以查到
}
}
}
}
上面查询分别返回什么?
term 查询 字段不分词 ,可以再mapping 中设置 keyword
POST /products_test/_search
{
//"explain": true,
"query": {
"constant_score": { // 忽视计算分数带来的性能影响
"filter": {
"term": {
"productID.keyword": "XHDK-A-1293-#fJ3"
}
}
}
}
}
post product_test/_search
{
"query":{
"match":{
"desc":{
"query":"dejxv"
}
}
}
}
match 与 match_phrase 区别?
原文:https://www.cnblogs.com/qlsem/p/15149220.html