在弹性搜索中将数字字段索引为int和string [英] indexing numeric field as both int and string in elastic search
问题描述
如何使用multi_field将数字字段作为整数和字符串进行索引。由于multi_field现在已被弃用。如何使用版本2.x中的fields字段实现相同的操作。我听说过一个领域可以使用领域以不同的方式索引和分析。但是,在弹性搜索中可以将其作为不同的类型进行索引吗?
How can I index a numeric field as both a integer and string using multi_field . As multi_field is deprecated now. How can I achieve the same using the "fields" field in version 2.x. I have heard that a field can be indexing and analysed in different ways using "fields". But can it be indexed as different types in elastic search?
我所面临的问题是弹性搜索中的古典数字字段搜索突出问题,我无法获得数字字段突出显示。所以我想将字段索引为字符串和int,以便我可以搜索,突出显示和对数据执行范围操作。
The issue that I am facing is the classical numeric field search highlighting issue in elastic search.where I could not get numeric fields highlighting. So I want to index the field as string and int so that I can search, highlight and perform range operations on the data.
推荐答案
您可以使用字段
将您的数字 string
以及
You can use fields
like this to have your numeric as string
as well:
{
"mappings": {
"test": {
"properties": {
"my_numeric": {
"type": "integer",
"fields": {
"as_string": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
}
这篇关于在弹性搜索中将数字字段索引为int和string的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!