我对多面搜索很陌生,所以我很难理解这个......但是这里有:
假装我有Item
一个包含SubItem
s 的集合,并且SubItem
有一个指示状态的枚举 - 我已经成功地在两个类别上启用了分面搜索,Item
并SubItem
使用了这个索引定义:
public class FacetIndexItems : AbstractIndexCreationTask<Item>
{
public const string FacetId = "facets/Items";
public const string ItemCategoryFacetName = "Category";
public const string SubItemCategoryFacetName = "SubItems_Category";
public FacetIndexItems()
{
Map = items => from item in items
from subItem in item.SubItems
select new
{
Category = item.Category,
SubItems_Category = subItem.Category
};
}
}
这FacetSetup
:
new FacetSetup
{
Id = FacetIndexItems.FacetId,
Facets =
{
new Facet {Name = FacetIndexItems.ItemCategoryFacetName},
new Facet {Name = FacetIndexItems.SubItemCategoryFacetName}
}
}
到现在为止还挺好!
现在,假设它SubItem
有一个Status
属性——有没有办法将每个方面的结果划分为不同的状态?
例如,查询这些数据:
{
Category: "wut",
SubItems: [
{Category: "bim", Status: "good"},
{Category: "bim", Status: "good"},
{Category: "bim", Status: "bad"}
]
}
byitem.Category.In("wut") && item.SubItems.Any(s => s.Category.In("bim"))
会产生类似的结果
{
Category: {
"good": 2
"bad": 1
},
SubItems_Category: {
"good": 2
"bad": 1
}
}
I am unsure whether this is actually possible to do with faceted search, and I am definitely open to alternatives if my approach is wrong.