EPiServer Find Searching Two Types

AB
AB
Vote:
 

Hi all,

I have EPiServer Find setup on a 7.5 site.

Basically, when a search has been performed I need to return two types only (one of 'BasePage' type and the other of media type 'DocumentFile').  The results page will show a Title, Summary and Url for each search result.

I have tried using the MultiSearch method which binds to a custom object that I have created. However, the result object comes back with two collections (one for BasePages and one for DocumentFiles).  It also appears that MultiSearch does not support pagination as Take() and Skip() arent available for the query.

Has anyone any advice as to the best way of achieving searching on two types, with pagination support and able to bind to a custom object? Do I need to run two seperate queries and amalgamate the results?

Thanks

Adam

#118770
Mar 13, 2015 12:35
Vote:
 

Hi,

Please have a look at unified search http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-Find/9/DotNET-Client-API/Searching/Unified-search/. I think that's what you're looking for.

#118796
Mar 14, 2015 7:12
Vote:
 

As Johan says, unified search can work but you could also search over multiple types with includetype. We do just that and then returns a custom object.

Read more about it here:

http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-Find/8/DotNET-Client-API/Searching/Searching-over-multiple-types/

#118800
Mar 14, 2015 19:09
AB
Vote:
 

Hi Henrik, I like the includetype approach that returns a cusom object.  However, I cannot seem to use 'InField' method to search on certain properties.  Any ideas?

Thanks

Adam

#118836
Mar 16, 2015 11:27
Vote:
 

I solved it by doing this;

I search for a baseclass and then if user have checked on block that they only want certain types I do something like below. ;

                IList<Type> types = new List<Type>();

                types.Add(typeof(NewsInformationPage));
                types.Add(typeof(ProductPage));

                
                searchQuery = searchQuery.FilterByExactTypes(types as IEnumerable<Type>);

Workes like a charm for me. 

or something like this I guess would be even cleaner;

searchQuery = searchQuery.FilterByExactTypes(new [] {typeof(InformationPage), typeof(ProductPage)});

/Jens

Oh right, I didn't quite read the whole post :-D Sorry bout that. 

#120041
Edited, Apr 09, 2015 10:17
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.