如何指定以数组内部属性为目标的多字段索引映射?
例如
Document
--------
ID: 1
Title: Some title goes here
Content: Some content goes here
SubDocuments:[{"Title:"Some title"},{"Title:"Some title"}]
如何指定一个索引映射,该索引映射将SubDocuments中的Title作为触摸和未触摸的变体?
由于
答案 0 :(得分:0)
Arrays,它们不需要特定的映射。您只需将SubDocuments
字段映射为object
(或nested
对象),然后将Title
字段映射为该对象中的多字段。
{
"your_type" : {
"properties" : {
"ID" : {"type" : "long"},
"Title" : {"type" : "string"},
"Content" : {"type" : "string"},
"SubDocuments" : {
"properties" : {
"Title" : {
"type" : "string",
"fields": {
"raw": {
"type" : "string",
"index" : "not_analyzed",
}
}
}
}
}
}
}
}
值得注意的是,如果您想要将其他字段添加到SubDocuments
并且您需要查询这些SubDocuments
字段,那么将SubDocuments
映射为{{3}可能更明智一些像这样:
{
"your_type" : {
"properties" : {
"ID" : {"type" : "long"},
"Title" : {"type" : "string"},
"Content" : {"type" : "string"},
"SubDocuments" : {
"type": "nested", <---- add this
"properties" : {
"Title" : {
"type" : "string",
"fields": {
"raw": {
"type" : "string",
"index" : "not_analyzed",
}
}
}
}
}
}
}
}
然后,在您的文档中,SubDocuments.Title
将是包含已分析变体的字段,而SubDocuments.Title.raw
将是包含精确和未分析字符串值的另一个字段。