我打算将Elastic Search用作主数据存储区,而我的文档就像嵌套数据一样嵌套。事件有3级嵌套数据。
{
"Date": "2015-10-21",
"Hour": "7",
"Minute": "15-29",
"Domain": "abc.com",
"Processed_at": "10/23/2015 9:47 UTC"
"Events": [
{
"Name": "visit",
"Count": "188",
"Attributes_Aggregations": [
{
"Name": "price",
"Value_Aggregations": [
{
"Value": "$125",
"Count": "188",
"Unique_Users": [
{
"ID": "CL_2135514566_1427476812_392007750_2004930118",
"Count": "38"
},
{
"ID": "CL_2135514566_1427476812_392007750_2004930119",
"Count": "32"
},
....
]
},
....
]
},
{
"Name": "color",
"Value_Aggregations": [
{
"Value": "red",
"Count": "188",
"Unique_Users": [
{
"ID": "CL_2135514566_1427476812_392007750_2004930118",
"Count": "38"
}
]
}
]
},
...
]
},
{
"Name": "order_created",
"Count": "159",
"Attributes_Aggregations": [
{
"Name": "price",
"Value_Aggregations": [
{
"Value": "$125",
"Count": "159",
"Unique_Users": [
{
"ID": "CL_2135514566_1427476812_392007750_2004930122",
"Count": "32"
},
....
]
}
]
},
]
},
]
}
如果我考虑使用父/子关系结构,但根据Elastic document,此级别的父/子查询将变慢。
还有其他想法可以将文档设计为最适合弹性搜索吗?
我想要的查询将使用文档的所有键进行过滤。也可以使用范围和数量。
答案 0 :(得分:2)
答案 1 :(得分:1)
弹性搜索是一个很棒的工具,但嵌套数据有一个重大缺陷,问题是ES会压平对象数组,所以如果查询嵌套信息,它会全部返回。
https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html
例如,如果您查询Unique_Users.Count=38
,它将返回
{
"ID": "CL_2135514566_1427476812_392007750_2004930118",
"Count": "38"
},
{
"ID": "CL_2135514566_1427476812_392007750_2004930119",
"Count": "32"
}
因为此特定数组(Unique_Users
)的字段Count
与38
匹配