拼写错误的建议(“你的意思是”)与短语建议和空白更正ElasticSearch

xmjla07d  于 2021-06-14  发布在  ElasticSearch
关注(0)|答案(1)|浏览(576)

我使用默认的分析器“英语”搜索文件,它是相当不错的。但我也需要“你的意思是”结果时,搜索查询拼写错误或搜索这样的拼写错误的阶段。
我需要什么样的分析器/过滤器/查询来实现这样的行为?
源文本

Elasticsearch is a distributed, open source search and analytics engine for all types of data,
including textual, numerical, geospatial, structured, and unstructured. Elasticsearch is built
on Apache Lucene and was first released in 2010 by Elasticsearch N.V. (now known as Elastic).
Known for its simple REST APIs, distributed nature, speed, and scalability, Elasticsearch is
the central component of the Elastic Stack, a set of open source tools for data ingestion,
enrichment, storage, analysis, and visualization. Commonly referred to as the ELK Stack 
(after Elasticsearch, Logstash, and Kibana), the Elastic Stack now includes a rich collection
of lightweight shipping agents known as Beats for sending data to Elasticsearch.

搜索词
搜索查询=>你是说吗?
缺信之类的
elasticsearch=>ElasticSearch
distribated=>分布式
apacje=>Apache
额外空间
ElasticSearch=>ElasticSearch
没有空间
开源=>开源
拼写错误的短语
serach engne=>搜索引擎

mlnl4t2r

mlnl4t2r1#

你的第一个丢失的字母或其他东西的例子可以实现使用模糊查询和第二个使用自定义分析器使用ngram或边缘ngram标记器的例子,请参阅我的博客上的自动完成。
在示例文档中添加模糊查询示例
索引Map

{
    "mappings": {
        "properties": {
            "title": {
                "type": "text"

            }
        }
    }
}

为示例文档编制索引并使用以下搜索查询

{
    "query": {
        "fuzzy": {
            "title": {
                "value": "distributed"
            }
        }
    }
}

和搜索资源

"hits": [
            {
                "_index": "didyou",
                "_type": "_doc",
                "_id": "2",
                "_score": 0.89166296,
                "_source": {
                    "title": "distribated"
                }
            }
        ]

以及 Elasticsearch ```
{
"query": {
"fuzzy": {
"title": {
"value": "Elasticsearch"
}
}
}
}

和搜索结果

"hits": [
{
"_index": "didyou",
"_type": "_doc",
"_id": "1",
"_score": 0.8173577,
"_source": {
"title": "Elastisearch"
}
}
]

相关问题