【问题标题】:ElasticSearch suggesting from the middle of the phraseElasticSearch 从短语中间建议
【发布时间】:2017-09-15 22:50:08
【问题描述】:

请帮助我选择 ElasticSearch 建议类型。

我有包含大量公司的 ElasticSearch 索引,其名称如下:“JSC Some company”、“JSC Another company”等等。

CompletionSuggester 不起作用,因为用户更喜欢类型:“Some co...”,但仅当用户以“JSC Some co...”开头时,建议器才有效

有什么方法可以在用户输入时创建快速搜索?

我想添加我的映射示例并建议查询示例,以便更清楚地了解问题:

curl -XPUT 'localhost:9200/tass_suggest_test/_mapping/company?pretty' -H 'Content-Type: application/json' -d'
{
   "company": {
            "properties": {
                "id": {
                    "type": "integer"
                },
                "inn": {
                    "type": "keyword"
                },
                "innSuggest" : {
                    "type" : "completion",
                    "analyzer": "whitespace"
                }
            }
        }
}
'

curl -XGET 'localhost:9200/tass_suggest_test/_suggest?pretty' -H 'Content-Type: application/json' -d'
{
    "company-suggest" : {
        "prefix" : "78200",
        "completion" : {
            "field" : "innSuggest"
        }
    }
}
'

【问题讨论】:

    标签: elasticsearch search-suggestion


    【解决方案1】:

    您可以尝试通过以下方式使用 ngram 过滤器。

    "filter": {
        "suggest_filter": {
             "type"    : "ngram",
             "min_gram": 2,
             "max_gram": 7
         }
    },
    "analyzer": {
        "suggest_analyzer": {
             "type": "custom",
             "tokenizer": "whitespace",
             "filter": ["lowercase", "suggest_filter"]
         }
    }
    

    【讨论】:

    • 谢谢,但我认为这不是我想要的。我在我的索引字段中输入了“完成”类型。我使用完成类型是因为我想使用“_suggest”而不是“_query”,以便从搜索引擎获得近乎实时的答案。你能给我举个例子,我如何在“完成”字段中使用这个过滤器和分析器。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-10
    • 2017-10-23
    • 2016-04-21
    • 1970-01-01
    • 2013-09-25
    • 1970-01-01
    相关资源
    最近更新 更多