gpt4 book ai didi

elasticsearch - 使用嵌套类型文档创建索引

转载 作者:行者123 更新时间:2023-12-03 02:06:44 24 4
gpt4 key购买 nike

我尝试了以下代码来创建具有以下映射的索引。我正在尝试创建“嵌套”类型的索引。此代码未显示任何错误,但似乎无法正常工作。非常感谢您的帮助。

def setting():
return { "stringIndex_mapping" : {
"mappings" :
{
"stringindex" : {
"mappings" : {
"files" : {
"properties" : {
"BaseOfCode" : {
"type" : "long"
},
"BaseOfData" : {
"type" : "long"
},
"Characteristics" : {
"type" : "long"
},
"FileType" : {
"type" : "long"
},
"Id" : {
"type" : "string"
},
"Strings" : {
"type" : "nested",
"properties" : {
"FileOffset" : {
"type" : "long"
},
"RO_BaseOfCode" : {
"type" : "long"
},
"SectionName" : {
"type" : "string"
},
"SectionOffset" : {
"type" : "long"
},
"String" : {
"type" : "string"
}
}
},
"SubSystem" : {
"type" : "long"
}
}
}
}
}
}
}

}
def createIndex():
es = elasticsearch.Elasticsearch()
settings = setting()

es.indices.create(
index = "stringindex",
body = settings
)

最佳答案

您的映射的json结构有问题。

这就是我所改变的

从您的setting()方法返回此映射

{
"mappings": {
"files": {
"properties": {
"BaseOfCode": {
"type": "long"
},
"BaseOfData": {
"type": "long"
},
"Characteristics": {
"type": "long"
},
"FileType": {
"type": "long"
},
"Id": {
"type": "string"
},
"Strings": {
"type": "nested",
"properties": {
"FileOffset": {
"type": "long"
},
"RO_BaseOfCode": {
"type": "long"
},
"SectionName": {
"type": "string"
},
"SectionOffset": {
"type": "long"
},
"String": {
"type": "string"
}
}
},
"SubSystem": {
"type": "long"
}
}
}
}
}

我已经使用curl进行了测试,我相信这可以解决您的问题。

希望这可以帮助!!

关于elasticsearch - 使用嵌套类型文档创建索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25266698/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com