ElasticSearch:hieararchy级别数据的设计模式?

时间:2016-01-21 05:16:52

标签: elasticsearch

对于任何对象,我都有这种格式的数据

标题,描述,标签

例如,移动设备,平板电脑,房地产将有像这样的标签heirachy

Electronics - > Mobile -> Samsung
Electronics - > Mobile -> Nokia
Electronics - > Tablet -> Samsung
RealEstate - > Rent -> Villa

现在我想查询

1. find all "mobile" of brand "Samsung" that exist in "Electronics" category
2. find all "Tablet" of brand "Samsung" that exist in "Electronics" category
3. find all "Tablet" of brand "Samsung" that exist in "Electronics" category
3. find all "Villa" for "Rent" that exist in "RealEstate" category

如何为这种hearahi级数据设计ES模式?

1 个答案:

答案 0 :(得分:1)

对于具有许多可以查询的属性的平面结构,这感觉就像是最好的情况。

{
  "product": "mobile",
  "brand": "Samsung",
  "category": "Electronics",
  "AnotherProperty": "And so on"
}

这种非常基本的方法让您可以进行所需的所有查询。