1

我对多面搜索很陌生,所以我很难理解这个......但是这里有:

假装我有Item一个包含SubItems 的集合,并且SubItem有一个指示状态的枚举 - 我已经成功地在两个类别上启用了分面搜索,ItemSubItem使用了这个索引定义:

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.

4

1 回答 1

1

You would have to generate different values for each option, you can't do a facet on more than one field at a time. But you can generate fields at indexing time, so that does the same thing.

于 2013-05-03T05:58:29.023 回答