<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title type="text">Blog posts by Marcus Granström</title><link href="http://world.optimizely.com" /><updated>2014-02-12T15:10:57.0000000Z</updated><id>https://world.optimizely.com/blogs/Marcus-Granstrom/</id> <generator uri="http://world.optimizely.com" version="2.0">Optimizely World</generator> <entry><title>Multi Search with EPiServer Find 7.5</title><link href="https://world.optimizely.com/blogs/Marcus-Granstrom/Dates/2014/2/Multi-Search-with-EPiServer-Find-75/" /><id>&lt;p&gt;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&amp;lt;SearchResults&amp;lt;T&amp;gt;&amp;gt;. 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.&lt;/p&gt; &lt;style type=&quot;text/css&quot;&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt; &lt;pre class=&quot;language-csharp&quot;&gt;&lt;code&gt;results = service.MultiSearch&amp;lt;Article&amp;gt;()
                .Search&amp;lt;Article&amp;gt;(x =&amp;gt; x.For(&lt;span class=&quot;str&quot;&gt;&amp;quot;Banana&amp;quot;&lt;/span&gt;).InField(y =&amp;gt; y.Title))
                .Search&amp;lt;Article&amp;gt;(x =&amp;gt; x.For(&lt;span class=&quot;str&quot;&gt;&amp;quot;Annanas&amp;quot;&lt;/span&gt;).InField(y =&amp;gt; y.Title))
                .GetResult();&lt;/code&gt;&lt;/pre&gt;
&lt;style type=&quot;text/css&quot;&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style type=&quot;text/css&quot;&gt;
.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, &quot;Courier New&quot;, courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color:#f4f4f4;width:100%;margin:0em;}.csharpcode.lnum{color:#606060;}&lt;/style&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;pre class=&quot;language-csharp&quot;&gt;&lt;code&gt;IEnumerable&amp;lt;SearchResults&amp;lt;string&amp;gt;&amp;gt; results = service.MultiSearch&amp;lt;&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;&amp;gt;()
    .Search&amp;lt;Article, &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;&amp;gt;(x =&amp;gt; x.For(indexedArticle.Title).InField(y =&amp;gt; y.Title).Select(y =&amp;gt; y.Title))
    .Search&amp;lt;User, &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;&amp;gt;(x =&amp;gt; x.For(indexedUser.Name).InField(y =&amp;gt; y.Name).Select(y =&amp;gt; y.Name)).GetResult();&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;Happy Finding!&lt;/p&gt;</id><updated>2014-02-12T15:10:57.0000000Z</updated><summary type="html">Blog post</summary></entry></feed>