哪种结构更适合查询,例如:
人有5个香蕉和1个苹果。
人有5根香蕉或1个苹果。
嵌套?
{
id: 1,
has:
[
{
'name': 'banana',
'quantity': 5,
},
{
'name': 'apple',
'quantity': 1,
'species': 'gala'
}
]
}
还是固定插槽?
{
id: 1,
slot1: {
'name': 'banana',
'quantity': 5,
},
slot2: {
'name': 'apple',
'quantity': 1,
'species': 'gala'
}
slot3: null,
slot4: null
}
最佳答案
嵌套方法更简单:您可以执行一个简单的嵌套查询[1],而不必执行slot1或slot2 OR ...如果Person没有其他字段,则将每个“slot”作为文档编制索引将更加简单。
[1] http://www.elasticsearch.org/guide/reference/query-dsl/nested-query.html
关于elasticsearch - Elasticsearch 中哪种结构更适合搜索库存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10167748/