<?xml version="1.0" encoding="utf-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><language>en</language><title>Blog posts by David Winslow Find</title> <link>https://world.optimizely.com/blogs/david-winslow-find/</link><description></description><ttl>60</ttl><generator>Optimizely World</generator><item> <title>Nested queries in Episerver Find</title>            <link>https://world.optimizely.com/blogs/david-winslow-find/dates/2016/9/nested-queries-in-episerver-find/</link>            <description>&lt;h2&gt;&lt;/h2&gt;
&lt;h2&gt;VIP-Players-Union&lt;/h2&gt;
&lt;p&gt;So you finally got the promotion you were hoping for and now you the man in charge!&lt;/p&gt;
&lt;p&gt;As your first decision you obviously purchase a Episerver CMS and Episerver Find license. Everybody in the company applauds your decision and all are excited about the future possibilities with regards to Episerver Find.&lt;/p&gt;
&lt;p&gt;Your first task is to learn about the players that are part of your union. You crack open Visual studio and take a look at the current data model:&lt;/p&gt;
&lt;pre class=&quot;language-csharp&quot;&gt;&lt;code&gt;public class Team

{

&amp;nbsp;public Team(string name)

&amp;nbsp;{

&amp;nbsp; TeamName = name;

&amp;nbsp; Players = new List&amp;lt;Player&amp;gt;();

&amp;nbsp;}

&amp;nbsp;public string TeamName { get; set; }

&amp;nbsp;public List&amp;lt;Player&amp;gt; Players { get; set; }

}

&amp;nbsp;

public class Player

{

&amp;nbsp; public string FirstName { get; set; }

&amp;nbsp; public string LastName { get; set; }

&amp;nbsp; public int Salary { get; set; }

}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: &lt;em&gt;One of the lesser known features in Episerver Find is the support for nested queries. Its a very useful feature when you domain model allows for querying on a complex object structure.&amp;nbsp;&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;&lt;em&gt;Indexing&lt;/em&gt;&lt;/h3&gt;
&lt;p&gt;You know from your previous experience that data needs to be indexed correctly so that the queries can do their magic.&lt;/p&gt;
&lt;p&gt;Something like this will suffice:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre class=&quot;language-csharp&quot;&gt;&lt;code&gt;            client.Index(new Team(&quot;Real Madrid&quot;) {Players = new List&amp;lt;Player&amp;gt;() 
{ new Player() { FirstName = &quot;Cristiano&quot;, LastName = &quot;Ronaldo&quot;, Salary = 1000 }}});
            client.Index(new Team(&quot;Barcelona&quot;){Players = new List&amp;lt;Player&amp;gt;() 
{ new Player() { FirstName = &quot;Lionel&quot;, LastName = &quot;Messi&quot;, Salary = 999 }}});
            client.Index(new Team(&quot;Geriatrics&quot;){Players = new List&amp;lt;Player&amp;gt;() 
{ new Player() { FirstName = &quot;Judd&quot;, LastName = &quot;Lazarow&quot;, Salary = 99 }}});
            client.Index(new Team(&quot;Geriatrics&quot;){Players = new List&amp;lt;Player&amp;gt;() 
{ new Player() { FirstName = &quot;Lior&quot;, LastName = &quot;Lanzer&quot;, Salary = 99 }}});
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;h3&gt;Searching&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;:&lt;em&gt;With Nested queries you will be able to sort, filter and build facets on nested properties. You can read more about it &lt;a href=&quot;/link/f29fa3ea0bc040beac76f19f7417dcc7.aspx&quot;&gt;here&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;In order to present the data in a logical format we make use of the histogram facet functionality which allows us to group the data together in intervals.&lt;/p&gt;
&lt;p&gt;No presentation can be complete without an impressive chart and the board of directors was very pleased with the the abilities of their new CEO.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code&gt;result = client.Search&amp;lt;Team&amp;gt;().HistogramFacetFor(x =&amp;gt; x.Players, x =&amp;gt; x.Salary, 10).GetResult();&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;/link/2b3aac43514c4786a6d12fbaf6ab2b40.aspx&quot; width=&quot;469&quot; alt=&quot;Image histogram.png&quot; height=&quot;472&quot; /&gt;&lt;/p&gt;
&lt;h3&gt;&lt;/h3&gt;</description>            <guid>https://world.optimizely.com/blogs/david-winslow-find/dates/2016/9/nested-queries-in-episerver-find/</guid>            <pubDate>Tue, 20 Sep 2016 09:12:28 GMT</pubDate>           <category>Blog post</category></item></channel>
</rss>