ElasticSearch 和 Porterstem 分析器

发布于 2024-10-24 01:20:58 字数 1715 浏览 6 评论 0原文

我正在考虑使用 Elasticsearch 来提供我们网站的搜索功能。

我一直在尝试它,但无法启用 Porterstem 分析器(以便搜索战斗匹配战斗和战斗)。

这是我的输入的概要。

    curl -XPUT localhost:9200/local/ -d'
    index :                     
        analysis : 
            analyzer : 
                stemming : 
                    type : custom 
                    tokenizer : standard 
                    filter : [standard, lowercase, stop, porterStem] 
    '

    curl -XPUT localhost:9200/local/_mapping -d'{"properties": { "title" : { "analyzer" : "stemming", "type" : "string" }}}'

    curl -XPUT localhost:9200/local/article/1 -d'{"title": "Fight for your life"}'
    curl -XPUT localhost:9200/local/article/2 -d'{"title": "Fighting for your life"}'
    curl -XPUT localhost:9200/local/article/3 -d'{"title": "My dad fought a dog"}'
    curl -XPUT localhost:9200/local/article/4 -d'{"title": "Bruno fights Tyson tomorrow"}'

然而,搜索“fight”仅匹配第一个条目 - 包含确切术语的条目。

curl -XGET localhost:9200/local/_search?q=fight

似乎已经设置了正确的设置,但似乎不起作用。

      "indices" : {
        "local" : {
          "aliases" : [ ],
          "settings" : {
            "index.analysis.analyzer.stemming.type" : "custom",
            "index.analysis.analyzer.stemming.tokenizer" : "standard",
            "index.analysis.analyzer.stemming.filter.1" : "lowercase",
            "index.analysis.analyzer.stemming.filter.0" : "standard",
            "index.analysis.analyzer.stemming.filter.3" : "porterStem",
            "index.analysis.analyzer.stemming.filter.2" : "stop",
            "index.number_of_shards" : "5",
            "index.number_of_replicas" : "1"
          },

有人启动并运行了此功能并能够为我指明正确的方向吗?

I'm looking at using Elasticsearch to provide the search functions of our site.

I've been experimenting with it but am unable to enable the Porterstem analyser (so that a search for fight matches fights and fighting).

Here's a run down of my input.

    curl -XPUT localhost:9200/local/ -d'
    index :                     
        analysis : 
            analyzer : 
                stemming : 
                    type : custom 
                    tokenizer : standard 
                    filter : [standard, lowercase, stop, porterStem] 
    '

    curl -XPUT localhost:9200/local/_mapping -d'{"properties": { "title" : { "analyzer" : "stemming", "type" : "string" }}}'

    curl -XPUT localhost:9200/local/article/1 -d'{"title": "Fight for your life"}'
    curl -XPUT localhost:9200/local/article/2 -d'{"title": "Fighting for your life"}'
    curl -XPUT localhost:9200/local/article/3 -d'{"title": "My dad fought a dog"}'
    curl -XPUT localhost:9200/local/article/4 -d'{"title": "Bruno fights Tyson tomorrow"}'

However running a search for 'fight' only matches the first entry - the one that contains the exact term.

curl -XGET localhost:9200/local/_search?q=fight

The correct settings appear to have been set up but doesn't seem to work.

      "indices" : {
        "local" : {
          "aliases" : [ ],
          "settings" : {
            "index.analysis.analyzer.stemming.type" : "custom",
            "index.analysis.analyzer.stemming.tokenizer" : "standard",
            "index.analysis.analyzer.stemming.filter.1" : "lowercase",
            "index.analysis.analyzer.stemming.filter.0" : "standard",
            "index.analysis.analyzer.stemming.filter.3" : "porterStem",
            "index.analysis.analyzer.stemming.filter.2" : "stop",
            "index.number_of_shards" : "5",
            "index.number_of_replicas" : "1"
          },

Anyone got this functionality up and running and able to point me in the right direction?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

书间行客 2024-10-31 01:20:58

有一个使用自定义分析器和雪球词干分析器的示例配置:
为什么 ElasticSearch 找不到我的术语

There is an example config on using custom analyzers, using the snowball stemmer:
Why ElasticSearch is not finding my term

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文