AI OnAI Off
Then you need to check into nested queries. Check documentation here
That's exactly what nested queries were meant to support...
Hi,
I think you should be able to do this using TermsFacetFor.
Create an extension method to get the Ids:
public static class Extensions { public static List<int> Ids(this IEnumerable<Manufacturer> manufacturers) { return manufacturers.Select(x => x.Id).ToList(); } }
then make sure there are indexed:
SearchClient.Instance..Conventions.ForInstancesOf<Book>().IncludeField(x => x.Manufacturers.Ids());
Remember to reindex!
Since the Id's are ints and not strings, you'll need to do a small "hack" in order to get Find to accept the input:
.TermsFacetFor(x => (string)(object) x.Manufacturers.Ids())
I have an index of Products, each with a Manufacturer. I created a histogram facet for the Manufacturer Ids in this way:
and this worked just fine. Then I learned each Product can have a list of Manufacturers. How can I create a facet now?
For example, if the index contains Products:
{Product1
Manufacturers: [{Man1 Id: 1} {Man2 Id: 2}]
}
{Product2
Manufacturers: [{Man3 Id: 3} {Man2 Id: 2}]
}
I need to know that there is:
1 product with Manufacturer.Id 1
2 products with Manufacturer.Id 2
1 product with Manufacturer.Id 3
Thanks