Elasticsearch不返回单数/复数匹配 [英] Elasticsearch not returning singular/plural matches

查看:788
本文介绍了Elasticsearch不返回单数/复数匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用一个弹性搜索的PHP库来索引和在我的网站中找到文档。这是创建索引的代码:

I am using a php library of elasticsearch to index and find documents in my website. This is the code for creating the index:

curl -XPUT 'http://localhost:9200/test/' -d '
{
  "index": {
    "numberOfShards": 1,
    "numberOfReplicas": 1
  }
}'

然后使用curl XPUT将文档添加到索引中,并使用XGET查询索引。除了在返回结果时索引的单数和复数不匹配的事实外,这种方法很好。例如,当我搜索讨论时,不返回讨论的匹配,反之亦然。为什么会这样?我认为这是默认情况下在elasticsearch中照顾。有没有什么我们必须明确提及它匹配单数/复数形式?

I then use curl XPUT to add documents to the index and XGET to query the index. This works well except for the fact that singulars and plurals of query words are not matched across the index while returning results. For example, when I search for "discussions", the matches for "discussion" are not returned and vice versa. Why is this so? I thought this is taken care of by default in elasticsearch. Is there anything that we have to mention explicitly for it to match the singular/plural forms?

推荐答案

不知何故雪球不工作我...得到错误,像我在@ imotov的回答的评论中提到。
我使用搬运工干,它对我完美的工作。这是我使用的配置:

Somehow snowball is not working for me... am getting errors like I mentioned in the comment to @imotov's answer. I used porter stem and it worked perfectly for me. This is the config I used:

curl -XPUT localhost:9200/index_name -d '
{
"settings" : {
    "analysis" : {
        "analyzer" : {
            "stem" : {
                "tokenizer" : "standard",
                "filter" : ["standard", "lowercase", "stop", "porter_stem"]
            }
        }
    }
},
"mappings" : {
    "index_type_1" : {
        "dynamic" : true,
        "properties" : {
            "field1" : {
                "type" : "string",
                "analyzer" : "stem"
            },
            "field2" : {
                "type" : "string",
                "analyzer" : "stem"
            }
         }
      }
   }
}'

这篇关于Elasticsearch不返回单数/复数匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆