Skip to main content
1 of 4
Tamás Tárnok
  • 4.3k
  • 1
  • 20
  • 33

If you use Sitecore, then you don't need to deserialize the response from Solr. For that Sitecore has an API for it. Offical documentation is [here][1] how you can LINQ to Sitecore.

LINQ to Sitecore provides access to search the indexes, using standard LINQ queries in the same way that other LINQ providers, such as LINQ to SQL and LINQ to Objects, work. It uses the standard IQueryable interface and supports most of the available operations.

Sitecore supports two search providers: Lucene and Solr. The LINQ layer is an abstract layer that converts common queries to something that these search providers understand.

Basicly the query above will look like this:

using (var context = ContentSearchManager.GetIndex(item).CreateSearchContext())
{
   IQueryable<SearchResultItem> searchQuery = context
     .GetQueryable<SearchResultItem>()
     .Where(item => item.Content.Contains("[search term]"))
}

Worth to read the more about Sitecore Search API. Here is also a good post about it: https://soen.ghost.io/a-re-introduction-to-the-contentsearch-api-in-sitecore-part-1/ [1]: https://doc.sitecore.net/sitecore_experience_platform/developing/developing_with_sitecore/search_and_item_buckets/linq_to_sitecore

Tamás Tárnok
  • 4.3k
  • 1
  • 20
  • 33