gpt4 book ai didi

Elasticsearch - 通配符 vs 前缀 vs vs 正则表达式 vs query_string 差异和性能

转载 作者:行者123 更新时间:2023-12-02 22:54:39 26 4
gpt4 key购买 nike

我刚刚开始在我的项目中使用 Elasticsearch,我想像 sql 关键字一样搜索 '喜欢%' 做。

  • 谁能解释一下 之间的区别通配符 , 前缀 , 查询字符串正则表达式 ?
  • 哪个可以搜索最好性能 ?
  • 定义 是否是在产品标签之间快速搜索的最佳方式?关键字 字段并使用我提到的三种方式之一进行搜索?

  • 我感谢回答我的人。

    谢谢。

    最佳答案

    哪个查询更好?

    让我逐条回答。

    1. Could anyone please explain what are the differences between Wildcard, Prefix, query_string and Regexp?


    它们在可以做什么以及如何实现方面非常相似。事实上, wildcard , prefix , 和 regexp are equally bad in performance . query_string查询允许更复杂的查询,例如使用逻辑运算符,如 ORAND . query_string支持 wildcards ,我认为这与 wildcard 是相同的通配符查询确实如此。

    1. Which one can search with the best performance?


    底线:他们都很糟糕。

    1. Is it the best way to search rapidly between product tags with defining the keyword field and search with one of the three ways which I mentioned?


    我相信如果你使用 boolean filter查询以减少匹配文档的数量,那么性能应该会提高,但是性能提升可能仍然被上面的类似正则表达式的查询效率低下所淹没。

    如何使用 Elasticsearch 实现自动完成?

    正如你在上面的评论中提到的,你想实现一个自动完成,所以 search_as_you_type 数据类型可能正是您要查找的类型。

    另一个类似的功能是 suggesters .他们都将尝试使用更有效的基于术语的匹配,而不是基于正则表达式的匹配。

    希望有帮助!

    关于Elasticsearch - 通配符 vs 前缀 vs vs 正则表达式 vs query_string 差异和性能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59447163/

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