ElasticSearch映射不起作用 [英] ElasticSearch mapping doesn't work

查看:153
本文介绍了ElasticSearch映射不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为各个字段设置不同分析器的ElasticSearch索引。然而,我似乎找不到设置现场分析仪的方法;以下是我创建我的(测试)索引:

I'm trying to set up an ElasticSearch index with different analyzers for the individual fields. However, I can't seem to find a way to set field-specific analyzers; here's how I create my (test) index:

curl -XPOST localhost:9200/twitter
curl -XPUT 'http://localhost:9200/twitter/tweet/_mapping' -d '
{
    "tweet" : {
        "properties" : {
            "message" : {
                "type" : "string",
                "search_analyzer" : "snowball", 
                "index_analyzer" : "snowball"
            }
        }
    }
}'

如果我正确阅读文档,那么应该创建索引'twitter'使用tweet类型,消息字段的内容应通过雪球词干分析器进行分析。
为了测试这个,我尝试了以下查询:

If I read the documentation correctly, then this should create the index 'twitter' with the type 'tweet', and content for the 'message' field should be analyzed through the snowball stemming analyzer. To test for this, I tried the following queries:

curl -XPUT 'http://localhost:9200/twitter/tweet/1' -d '{
    "message" : "Look, a fighting War-Unicorn!"
}'
curl -XGET localhost:9200/twitter/_search?q=fight



如果我没有误会,那么这应该是一个打击,因为战斗是战斗的根源;问题是,它没有,我得到零点击。看起来好像ElasticSearch完全忽略了映射(即使ElasticSearch接受了所有这些查询,因为我们为每个查询都ok)。

If I'm not mistaken, then this should return a hit, as fight is the stem for fighting; the problem is, it doesn't, I'm getting zero hits. It appears as if ElasticSearch ignores the mapping entirely (even though ElasticSearch accepts all of these queries, as I get 'ok' back for each of them.)

已经尝试用雪球分析仪替换默认分析仪,然后工作;事情是,我完全需要有专门的分析仪,所以这不会帮助我。我也尝试过不同的分析仪器,例如将index设置为no,但无效。

I've already tried replacing the default analyzer with a snowball analyzer, and then it works; thing is, I totally need to have field-specific analyzers, so this isn't going to help me. I also tried different analyzers and things like setting "index" to "no", but to no avail.

我做错了什么?

推荐答案

要使用字段特定的分析器,您需要在查询中指定此字段。否则,将使用默认分析器。尝试

To use a field-specific analyzer you need to specify this field in the query. Otherwise, default analyzer is used. Try

curl -XGET 'localhost:9200/twitter/_search?q=message:fight'

curl -XGET 'localhost:9200/twitter/_search?df=message&q=looking'

这篇关于ElasticSearch映射不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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