我正在尝试将所有字段映射为text
。根据文档,这应该有效,但它没有:
PUT my_type
{
"mappings": {
"my_type": {
"dynamic_templates": [
{
"longs_as_strings": {
"match_mapping_type": "*",
"match": "*",
"mapping": {
"type": "text"
}
}
}
]
}
}
}
PUT my_type/my_type/1
{
"intfield": 5
}
GET my_type/_search
结果:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "my_type",
"_type": "my_type",
"_id": "1",
"_score": 1,
"_source": {
"intfield": 5
}
}
]
}
}
答案 0 :(得分:0)
我认为ES正确地索引您的数据。添加文档后,尝试获取索引的映射。执行:
mode
我想你会得到这样的东西:
query {
repository(owner:"google", name:"gson") {
object(expression: "gson-2.4:gson") {
... on Tree{
entries{
name
type
mode
}
}
}
}
}
如您所见,ES索引您GET my_type
喜欢文字。您可以使用此字段,例如文本字段。
当您尝试恢复数据时,ES“按原样”返回数据。但在索引中,它存储数据,如文本
答案 1 :(得分:0)
这是最终工作的解决方案:
{
"mappings": {
"my_record": {
"dynamic_templates": [{
"longs_as_strings": {
"match_mapping_type": "*",
"match": "*",
"mapping": {
"type": "text"
}
}
}]
}
}
}