Last updated: Oct 31 2016

Searching
Episerver Find excels in traditional, free-text search scenarios and data-centric queries involving exact matching using filters. Find also supports data aggregation using facets. This topic introduces search and filtering in Find.
Note: When querying for objects inheriting IContent , the GetContentResultextensions should be used. For information, see GetContentResult.
How it works
You search and query using an instance of the IClient interface. This, along with extension methods, offers a traditional, object-oriented API and convenient fluent API. Most documentation found here covers the fluent API.
Searching
You can execute a free-text search for objects of a specific via the GetResult method, which returns:
- An object with result items
- The number of documents that match the search query
- Facets
- Information about execution time
var searchResult = client.Search<BlogPost>()
.For("Beethoven")
.GetResult();
int numberOfDocsMatchingTheSearch = searchResult.TotalMatching;
int executionTime = searchResult.ServerDuration;
FacetResults facets = searchResult.Facets;
IEnumerable<SearchResultItem<BlogPost>> hits = searchResult.Hits;
Each hit object contains the indexed object, its ID, highlights (if requested), and its score.
var searchResult = client.Search<BlogPost>()
.For("Beethoven")
.GetResult();
foreach (var hit in searchResult.Hits)
{
string id = hit.Id;
BlogPost item = hit.Item;
Highlights highlights = hit.Highlights;
double? score = hit.Score;
}
Unless specified, searches are performed over all indexed properties, including nested properties. You can specify which properties to search.
client.Search<BlogPost>()
.For("Beethoven")
.InFields(
x => x.Title,
x => x.Tags,
x => x.Author.Name);
Filtering
The service and client API also supports filtering. If applied to a free text query, filtering restricts search results to those matching the filters.
client.Search<BlogPost>()
.For("Beethoven")
.Filter(x => x.Tags.Match("Music"));
If applied without a free text query, filters let you query for objects in an exact manner, similar to traditional database queries.
client.Search<BlogPost>()
.Filter(x => x.Tags.Match("Music"));
Do you have feedback on this documentation? Send an email to documentation@episerver.com. For development-related questions and discussions, refer to our Forums on https://world.episerver.com/forum/