elasticsearch 弹性搜索优先排序以搜索词开头的搜索结果
我需要对以搜索词开头的搜索结果进行优先级排序。我用了“匹配短语前缀”。我用了“匹配短语前缀”。但不起作用。 详情:elasticsearch 弹性搜索优先排序以搜索词开头的搜索结果,elasticsearch,lucene,full-text-search,search-engine,elasticsearch,Lucene,Full Text Search,Search Engine,我需要对以搜索词开头的搜索结果进行优先级排序。我用了“匹配短语前缀”。我用了“匹配短语前缀”。但不起作用。 详情: 质疑 GET /test/products/_search?pretty { "query": { "match_phrase_prefix": { "title": "iphone 5c" } } } 映射 curl -XGET
- 质疑 GET /test/products/_search?pretty { "query": { "match_phrase_prefix": { "title": "iphone 5c" } } }
- 映射
“映射”:{ “产品”:{ “财产”:{ “标题”:{ “类型”:“字符串”, “分析器”:“巴西人” } } } }curl -XGET 'localhost:9200/test/_analyze?analyzer=standard&pretty' -d 'Capa Bumper Iphone 5C' | grep token % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 532 100 511 100 21 32800 1347 --:--:-- --:--:-- --:--:-- 34066 "tokens" : [ { "token" : "capa", "token" : "bumper", "token" : "iphone", "token" : "5c",
在本例中,我需要的第一个结果是设备(Iphone 5c)
分析仪的使用导致了标记化问题。下面看看您的文档字段是如何标记的 您需要使用关键字标记器 在映射中添加关键字标记器:
在捕获第一个令牌的情况下,会是什么? "mappings": { "products": { "properties": { "title": { "type": "string", "analyzer": "brazilian" } } } }
curl -XGET 'localhost:9200/test/_analyze?analyzer=standard&pretty' -d 'Capa Bumper Iphone 5C' | grep token
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 532 100 511 100 21 32800 1347 --:--:-- --:--:-- --:--:-- 34066
"tokens" : [ {
"token" : "capa",
"token" : "bumper",
"token" : "iphone",
"token" : "5c",