我使用Elasticsearch(2.4)并且我有一个索引,其中一个字段理论上是在索引步骤上分析的。但是,在实践中,它没有被分析。我想我错过了什么,但是什么?
完整的索引定义:
{
"test_index": {
"aliases": {},
"mappings": {
"users": {
"properties": {
"name": {
"type": "string",
"analyzer": "my_analyser"
},
"id": {
"type": "long"
}
}
}
},
"settings": {
"index": {
"index_directly": "1",
"number_of_shards": "1",
"cron_limit": "50",
"creation_date": "1496150121337",
"analysis": {
"analyzer": {
"standard": {
"type": "standard",
"max_token_length": "255",
"stopwords": ""
},
"my_analyser": {
"type": "custom",
"tokenizer": "my_tokenizer"
}
},
"tokenizer": {
"my_tokenizer": {
"token_chars": [
"letter",
"digit"
],
"min_gram": "3",
"type": "ngram",
"max_gram": "3"
}
}
},
"fields": {
"name": {
"type": "text"
}
},
"number_of_replicas": "0",
"uuid": "lmwPFWoISlC2knZZn2nNZQ",
"version": {
"created": "2040599"
}
}
},
"warmers": {}
}
}
要编制索引的简单文档:
{
"id": 0,
"name": "John"
}
结果:
{
"_index": "test_index",
"_type": "users",
"_id": "0",
"_version": 1,
"found": true,
"_source": {
"id": 0,
"name": "John"
}
}
我的期望:
{
"_index": "test_index",
"_type": "users",
"_id": "0",
"_version": 1,
"found": true,
"_source": {
"id": 0,
"name": [
"Joh",
"ohn"
]
}
}
我在这个索引上有其他字段,我希望我的自定义分析器只在name
字段上。
答案 0 :(得分:1)
您的分析器不会影响_source
对象,它只会影响存储在索引中并用于搜索的结果术语