我需要优先考虑以搜索字词开头的搜索结果。我用了“match_phrase_prefix”。我用了“match_phrase_prefix”。但是没有用。
详细说明:
查询
GET /test/products/_search?pretty { "query": { "match_phrase_prefix": { "title": "iphone 5c" } } }
结果
"_score": 10.440153 title": "Capa de Tpu para Iphone 5c Modelo Apple + Película""_score": 9.981493, "title": "Capa Bumper Iphone 5C + Pelicula", "_score": 8.610232 "title": "Pelicula Protetora para Iphone 5C Transparente" "_score": 5.154923, "title": "iPhone 5c Apple 8GB com Tela de 4”, iOS7, Câmera 8MP, Touch Screen, Wi-Fi, 3G/4G, GPS, MP3 e Bluetooth - Rosa" "_score": 5.154923 "title": "iPhone 5c Apple 8GB com Tela de 4”, iOS7, Câmera 8MP, Touch Screen, Wi-Fi, 3G/4G, GPS, MP3 e Bluetooth - Branco" "_score": 5.154923 "title": "iPhone 5c Apple 8GB com Tela de 4”, iOS7, Câmera 8MP, Touch Screen, Wi-Fi, 3G/4G, GPS, MP3 e Bluetooth - Preto"
映射
{{1}}
在这个例子中我需要的第一个结果是设备(Iphone 5c)
答案 0 :(得分:2)
使用分析器导致标记化问题。请看下面的文档字段如何被标记化。
您需要使用关键字标记符。
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",
在地图中添加关键字tokenizer: