elasticsearch 如何忽略索引的动态字段,但需要存储值?
在每个文档中,我都有几个动态字段。我想在索引时忽略这些字段,但neet将完整的值存储在ES中。在这里,我尝试了对象类型和嵌套类型,但仍然添加了这些字段用于索引。此外,还超出了默认字段数 例如:elasticsearch 如何忽略索引的动态字段,但需要存储值?,elasticsearch,elasticsearch,在每个文档中,我都有几个动态字段。我想在索引时忽略这些字段,但neet将完整的值存储在ES中。在这里,我尝试了对象类型和嵌套类型,但仍然添加了这些字段用于索引。此外,还超出了默认字段数 例如: { "graphType": "Node", "id": "ETA:bb16f173-8152-4e18-ac15-410438ffaf8e", "type": "Stat
{
"graphType": "Node",
"id": "ETA:bb16f173-8152-4e18-ac15-410438ffaf8e",
"type": "StateNode",
"properties": {
"name": "ETA:ETAViolation",
"tenantId": "f9688078-9ff9-46b3-9b0d-d1b4d5f875d7",
"valueHistory": {
"1597952938315": "1"
},
"id": "ETA:bb16f173-8152-4e18-ac15-410438ffaf8e",
"type": "ETA:ETAViolation",
"value": {
"1597952938315": "1"
},
"fromId": "bb16f173-8152-4e18-ac15-410438ffaf8e",
"classType": "StateNode",
"sid": "ETA",
"cid": "ETAViolation"
}
}
{
"graphType": "Node",
"id": "ETA:8541fb08-8c83-4229-804b-92d57e22e9a2",
"type": "StateNode",
"properties": {
"name": "ETA:ETAViolation",
"tenantId": "f9688078-9ff9-46b3-9b0d-d1b4d5f875d7",
"valueHistory": {
"1597952938447": "3"
},
"id": "ETA:8541fb08-8c83-4229-804b-92d57e22e9a2",
"type": "ETA:ETAViolation",
"value": {
"1597952938447": "3"
},
"fromId": "8541fb08-8c83-4229-804b-92d57e22e9a2",
"classType": "StateNode",
"sid": "ETA",
"cid": "ETAViolation"
}
}
这是两个示例文档,每个文档中有两个字段value和valueHistory。在这些字段中,我得到了许多动态字段,如1597952938315和159795293831588。我想在索引时忽略这些字段,但需要将这些字段存储在ES索引中
任何人都可以帮忙。提前感谢。您的映射可能是这样的,我省略了一些重复字段
{
"mappings": {
"post": {
"dynamic": "strict",
"properties": {
"graphType": {
"type": "keyword"
},
"id": {
"type": "keyword"
},
"type": {
"type": "keyword"
},
"name": {
"type": "keyword"
},
"tenantId": {
"type": "keyword"
},
"nested_value": {
"type": "nested",
"properties": {
"key": {
"type": "long",
"store": true
},
"value": {
"type": "integer",
"store": true
}
}
},
"from_id": {
"type": "keyword"
},
"classType": {
"type": "keyword"
},
"sid": {
"type": "keyword"
},
"cid": {
"type": "keyword"
}
}
}
}
}
您需要像这样插入数据:
{
"graphType": "Node",
"id": "ETA:bb16f173-8152-4e18-ac15-410438ffaf8e",
"type": "StateNode",
"name": "ETA:ETAViolation",
"tenantId": "f9688078-9ff9-46b3-9b0d-d1b4d5f875d7",
"nested_value": [
{
"key": 1597952938315,
"value": 1
}
],
"from_id": "bb16f173-8152-4e18-ac15-410438ffaf8e",
"classType": "StateNode",
"sid": "ETA",
"cid": "ETAViolation"
}
您可以在嵌套字段中设置关键字和值。您还可以轻松地对其进行搜索。您好,您可以更改文档结构吗?我只是想知道我是否可以为您提供一个需要对映射进行一些更改的解决方案。如果您需要,请更改结构并提供解决方案。