gpt4 book ai didi

elasticsearch - Elasticsearch 优先搜索以搜索词开头的结果

转载 作者:行者123 更新时间:2023-11-29 02:56:20 24 4
gpt4 key购买 nike

我需要对以搜索词开头的搜索结果进行优先排序。我使用了“match_phrase_prefix”。我使用了“match_phrase_prefix”。但是不起作用。

详细信息:

  • 查询

         GET /test/products/_search?pretty        {           "query": {            "match_phrase_prefix": {             "title": "iphone 5c"            }          }        }
  • Result

        "_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"
  • 映射

        "mappings": {        "products": {          "properties": {            "title": {               "type": "string",               "analyzer": "brazilian"            }          }        }    }



In this example I need the first result is the device (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",

在您的映射中添加关键字分词器:

https://www.elastic.co/blog/starts-with-phrase-matching

关于elasticsearch - Elasticsearch 优先搜索以搜索词开头的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28820243/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com