【发布时间】:2017-05-30 14:52:16
【问题描述】:
我使用 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 字段上。
【问题讨论】:
-
分析过程不会修改你扔进 ES 的源文件。标记
Joh和ohn在您的索引中,但源文档永远不会包含它们。 -
好的,谢谢@Val 有没有办法获取索引值? (没有分析 API)?