小编典典

Elasticsearch不返回单/复数匹配

elasticsearch

我正在使用Elasticsearch的php库对我的网站进行索引和查找文档。这是用于创建索引的代码:

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

然后,我使用curl
XPUT将文档添加到索引,并使用XGET查询索引。除了返回结果时跨索引的单数和复数查询词不匹配之外,这种方法效果很好。例如,当我搜索“讨论”时,不返回“讨论”的匹配项,反之亦然。为什么会这样呢?我认为这是默认情况下在Elasticsearch中处理的。为了匹配单数/复数形式,有什么要明确提及的吗?


阅读 519

收藏
2020-06-22

共1个答案

小编典典

不知何故,滚雪球对我不起作用…正在收到像我在@imotov的答案的评论中提到的错误。我使用了搬运工杆,它非常适合我。这是我使用的配置:

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"
            }
         }
      }
   }
}'
2020-06-22