I have an index of Product objects, each of which has a Manufacturer which has a Guid for an id. I would like to find out, for each Manufacturer, how many products it has.
var res = client.Search().TermsFacetFor(x => x.man.guid.ToString()).Take(0).GetResult();
var hist = res.TermsFacetFor(x => x.man.guid.ToString());
But it doesn't work.
Of course if I directly save the guid as a string, it works. However, it seems like a lot of unnecessary conversion: to index the object, I convert the Guid to a string, then when get the results of a search I may have to convert the string back to a Guid. Is there a better way?
You could do this:
.TermsFacetFor(x => (string)(object) x.Man.Guid)
var facets = result.TermsFacetFor(x => (string) (object) x.Man.Guid);
You'll have to convert the facet term to a guid though, but I would not worry about that.
And don't worry about the type conversion in the query. The Find framework will actually just look at the field name, which is "Man.Guid" in this case.