英文:
Elasticsearch dynamic_templates regex matching
问题
我想要userId
字段在文档中的类型为long
。下面的代码仅适用于顶层的userId
字段。如何使其在内部对象中生效?
"mappings": {
"dynamic_templates" : [
{
"userId" : {
"match" : ".*userId.*|userId",
"match_pattern" : "regex",
"mapping" : {
"type" : "long"
}
}
}
]
}
英文:
I'd like userId
field to be long
type where it appears on the document.
Below only works for the top userId
field.
How to make it pick up from inner objects?
"mappings": {
"dynamic_templates" : [
{
"userId" : {
"match" : ".*userId.*|userId",
"match_pattern": "regex",
"mapping" : {
"type" : "long"
}
}
}
]
答案1
得分: 0
根据文档中的说明,您应该尝试使用 path_match
:
"mappings": {
"dynamic_templates" : [
{
"userId" : {
"path_match" : ".*userId*",
"mapping" : {
"type" : "long"
}
}
}
]
英文:
As written in the documentation you should try path_match
:
"mappings": {
"dynamic_templates" : [
{
"userId" : {
"path_match" : ".*userId*",
"mapping" : {
"type" : "long"
}
}
}
]
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论