gpt4 book ai didi

elasticsearch - 在 elasticsearch 中,是否有一些方法可以降低一组搜索词的重要性?

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

理想情况下,我想降低某些词的重要性,例如“store”、“shop”、“restaurant”。

当用户搜索“牛排餐厅”时,我希望“Jimmy's Steak Restaurant”与“Ralph's Steak House”一样重要。我希望通过严重降低“餐厅”一词(连同 20-50 个其他词)的重要性来实现这一目标。

停用词对某些词很有效,例如“a”、“the”、“of”等,但它们是全有或全无的。

有没有办法在索引或映射级别为每个单词提供权重或提升值?

我可能可以在查询级别完成此操作,但如果我需要减少 50 个单词的影响,那可能会非常糟糕。

这是一个通用的例子。在我实际的复杂解决方案中,我确实需要减少相当多的搜索词的影响。

最佳答案

我认为在编制索引期间不可能指定术语级别的提升。 In this thread , Shay 提到这在 Lucene 中是可能的,但通过 API 显示它是一个棘手的功能。

另一个relevant thread , 暗示同样的事情。 Shay 建议尝试使用 custom_score 查询对其进行排序:

I think that you should first try and solve it on the search side. If you know the weights when you do a search, you can either construct a query that applies different boosts depending the tag, or use custom_score query.

Custom_score query is slower than other queries, but I suggest you run and check if it's ok for you (with actual data, and relevant index size). The good thing is that if its slow for you (and slow here means both latency and QPS under load), you can always add more replicas and more machines to separate the load.

Here is an example of a custom_score query在有点相似的术语水平上提升(除了它是针对只有一个类别术语的特殊领域,所以这可能不适用)。将脚本分解为 native 脚本可能比使用 mvel 更容易,因为您会有一大堆单词。

作为替代方案,也许添加一个 synonym token filter可以互换“商店”、“餐厅”、“商店”等词吗?

关于elasticsearch - 在 elasticsearch 中,是否有一些方法可以降低一组搜索词的重要性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14468221/

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