es 如何在搜索苹果手机的时候只出苹果手机,搜苹果可能出苹果手机,也可能出真实的苹果
搜挖掘机只出挖掘相关内容,不出飞机、机械,机器等和挖掘不相关的内容
比如下面的例子,如何搜苹果手机只出手机相关内容,搜挖掘机配件只出挖掘机相关的内容,而不是搜苹果手机,挖掘机、飞机都能搜出来
PUT /product
{
"settings": {
"number_of_replicas": 1,
"number_of_shards": 1,
"analysis.analyzer.default.type": "ik_max_word"
},
"mappings": {
"properties": {
"id":{
"type": "long"
},
"title":{
"type": "text",
"fields": {
"titleName":{
"type":"keyword"
}
}
},
"tags":{
"type": "nested"
}
}
}
}
POST /_bulk?filter_path=items.*.error
{"create":{"_index":"product","_id":1}}
{"title":"我是苹果手机1","id":"1"}
{"create":{"_index":"product","_id":2}}
{"title":"苹果手机","id":"2"}
{"create":{"_index":"product","_id":3}}
{"title":"四川苹果","id":"3"}
{"create":{"_index":"product","_id":4}}
{"title":"广州苹果","id":"4"}
{"create":{"_index":"product","_id":5}}
{"title":"挖掘机零件","id":"5"}
{"create":{"_index":"product","_id":6}}
{"title":"挖掘机配件","id":"6"}
{"create":{"_index":"product","_id":7}}
{"title":"飞机配件","id":"7"}
{"create":{"_index":"product","_id":8}}
{"title":"飞机零件","id":"8"}
GET /product/_search
{
"query": {
"match": {
"title": "苹果手机"
}
}
}
GET /product/_search
{
"query": {
"match": {
"title": "挖掘机配件"
}
}
}