How to do distinct in Find Query

Vote:
 

Something similar to this below
var query = people.DistinctBy(p => new { p.Id, p.Name });

Is there a way to do this in Episerver Find? Or override any method to make this work?

#117008
Feb 09, 2015 23:50
Vote:
 

Why do you need to do distinct? Sounds like your index has duplicates.

Is your p.Id property decorated with [Id]?
http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-Find/8/DotNET-Client-API/Indexing/

Try that and then you won't get duplicates.

#117019
Feb 10, 2015 9:07
Vote:
 

I think the requirement is that We have one to many relationship between product to variant. We want to search through all the variants but then display only the parent product on the results page. 

E.g. 

A product is a vaialable in red, green and yellow color. The color information is stored in the variant object. But if someone searches for yellow, result will be retruning the product object of yellow variantion. 

Any help in this regard would be approcaiated. 

#117055
Feb 10, 2015 19:26
Vote:
 

I would include the variants on a product property.

You can target searching on enumerable properties as described here:
http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-Find/8/DotNET-Client-API/Searching/Filtering/Complex-objects/

You could also assemble the variants' text you want searchable on a product string property.

#117070
Feb 11, 2015 8:41
Vote:
 

Thanks for your input Johan,

Nice approach. How do we use the enumerable properties in .For("").InFields(....)? 

Thanks,

Syed

#117097
Feb 11, 2015 16:05
Vote:
 

Not sure but I recall Elasticsearch uses a dot syntax so something like this could work:
InFields(x => "product.variants.title", x => "product.variants.title")

I'd recommend creating a suitable property to get better control and shorter queries.

#117100
Feb 11, 2015 16:43
Vote:
 

This syntax does not work with Find. I feel like there has to be a typed search available through the collection of objects if EPI server Find supports indexing the collections. 

Any help in this regard would be highly approciated. 

#117361
Feb 18, 2015 23:08
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.