【问题标题】:i need to restrict the results based on the searched key like - full text search我需要根据搜索的关键字限制结果,例如全文搜索
【发布时间】:2023-01-11 23:49:32
【问题描述】:

我正在使用范围为 2 到 25 的边缘 ngram。

我正在尝试搜索“测试”之类的关键字,但得到的结果是“测试”和“测试”之类的词。

如果我的搜索键是“测试”,那么在这种情况下我都可以得到测试和测试。

我需要做什么只得到搜索键“testing”的结果“testing”,它不应该匹配“test”

我的索引配置:

$config = '{"settings": {
                    "number_of_shards": 1, 
                    "analysis": {
                        "filter": {
                            "autocomplete_filter": { 
                                "type":     "edge_ngram",
                                "min_gram": 2,
                                "max_gram": 20
                            }
                        },
                        "analyzer": {
                            "autocomplete": {
                                "type":      "custom",
                                "tokenizer": "standard",
                                "filter": [
                                    "lowercase",
                                    "autocomplete_filter" 
                                ]
                            }
                        }
                    },
                    "/":{}
                }}';

【问题讨论】:

    标签: php elasticsearch search elasticsearch-5 n-gram


    【解决方案1】:

    您需要将 keyword 用作 search time analyzer 这样它就不会标记您的搜索词并会为您带来预期的搜索结果。

    【讨论】:

      猜你喜欢
      • 2010-10-03
      • 1970-01-01
      • 2011-02-09
      • 2010-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多