Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Marcus Granström
Feb 12, 2014
  4474
(2 votes)

Multi Search with EPiServer Find 7.5

With the release of EPiServer 7.5 we of course also released a 7.5 version of EPiServer Find. This release includes among other things a new feature to be able to handle multiple searches in one request. It will then return an IEnumerable<SearchResults<T>>. There are several use cases for this, several queries for a specific page can now be done in one round trip. Here you see a simple example of how to do it with the api.

results = service.MultiSearch<Article>()
                .Search<Article>(x => x.For("Banana").InField(y => y.Title))
                .Search<Article>(x => x.For("Annanas").InField(y => y.Title))
                .GetResult();

In the example above both queries search in the Article type and also returns the article type. It is also possible to search in different types and return a different type. Using the projections that are very powerful in EPiServer Find.

IEnumerable<SearchResults<string>> results = service.MultiSearch<string>()
    .Search<Article, string>(x => x.For(indexedArticle.Title).InField(y => y.Title).Select(y => y.Title))
    .Search<User, string>(x => x.For(indexedUser.Name).InField(y => y.Name).Select(y => y.Name)).GetResult();

The results are always returned in the same way as they are searched for. So the first result will be the first query. Also these will of course only count as one query against the index and will hopefully save you from any problems with too many requests.

Happy Finding!

Feb 12, 2014

Comments

Petter Klang
Petter Klang Feb 12, 2014 05:05 PM

Been looking forward to this!

Good job keep it up!

Petter Klang
Petter Klang Feb 12, 2014 05:05 PM

(double post)

Feb 12, 2014 06:37 PM

Very nice! So where is this documented? I'm particularily interested in the MultiUnifiedSearch functionality.

Yauheni Aliashkevich
Yauheni Aliashkevich Mar 29, 2014 10:03 AM

Just to let you know: Multi Search fails if you use Take()/Skip() in your queries

Please login to comment.
Latest blogs
Solving the mystery of high memory usage

Sometimes, my work is easy, the problem could be resolved with one look (when I’m lucky enough to look at where it needs to be looked, just like th...

Quan Mai | Apr 22, 2024 | Syndicated blog

Search & Navigation reporting improvements

From version 16.1.0 there are some updates on the statistics pages: Add pagination to search phrase list Allows choosing a custom date range to get...

Phong | Apr 22, 2024

Optimizely and the never-ending story of the missing globe!

I've worked with Optimizely CMS for 14 years, and there are two things I'm obsessed with: Link validation and the globe that keeps disappearing on...

Tomas Hensrud Gulla | Apr 18, 2024 | Syndicated blog

Visitor Groups Usage Report For Optimizely CMS 12

This add-on offers detailed information on how visitor groups are used and how effective they are within Optimizely CMS. Editors can monitor and...

Adnan Zameer | Apr 18, 2024 | Syndicated blog