douzhouqin6223 2018-11-14 15:32
浏览 77

在elasticsearch中提升特定文档

I'm creating an autocomplete query for hotels and destinations. I want than when i type Can or Canc i see Cancun in the first results of my query. My php-code is the follow:

$params = [
    'index' => ['hotels', 'destination_ngrams'],
    'type' => ['hotel','city'],
    "size" => 100   ,
    'body' => [
        'query' => [
            'multi_match' => [
                "type" => "best_fields",
                "query" => $text,
                "fields" => ["destination_name_*^3","hotel_name"],
                "fuzziness" => "AUTO"
            ],
        ]
    ]
];

I already have a list of popular "citys and hotels" that i want to see first in my autocomplete.

Or, how can I give priority to destinations that start exactly with the same letters?

I think i can put a "relevance" value when I make the bulk code, but i don't be shure what way to follow

Anyone can help me?, i apresiate it alot!

Thanks!!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
    • ¥50 汇编语言除法溢出问题
    • ¥65 C++实现删除N个数据列表共有的元素
    • ¥15 Visual Studio问题
    • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
    • ¥20 求一个html代码,有偿
    • ¥100 关于使用MATLAB中copularnd函数的问题
    • ¥20 在虚拟机的pycharm上
    • ¥15 jupyterthemes 设置完毕后没有效果
    • ¥15 matlab图像高斯低通滤波