Result items for Sitecore content search Skip to main content Skip to footer

Result items for Sitecore content search.

The base result item for the Sitecore content search is called SearchResultItem and is located with the Sitecore.ContentSearch.SearchTypes namespace, this by default has quite a fair few useful properties attached to it out of the box such as:

  1. TemplateName
  2. TemplateId
  3. Content
  4. Language
  5. Paths


The properties above are available for use within queries against the index to refine your result, you can read more on writing these here. You’re not limited to just the out of the box properties, you are able to create your Models that inherit from the SearchResultItem and then add your own properties that are mapped to index fields using the IndexField data annotation with in your code file.

What does that look like?

The below is a model of what my news items look like, the properties you can see that I have added are

1) Title 
a. Potential Sitecore field types: single-line text, multi-line text, rich text, text and memo field types.
2) Date 
a. Potential Sitecore field types: date and datetime field types.
3) News Type 
a. Potential Sitecore field types: droplink, droptree, grouped droplink and tree field types.
4) Authors
a. Potential Sitecore field types: checklist, multilist, treelist, treelistex, tree list, multilist with search and treelist with search field types.
5) Show In Search Listing
a. Sitecore field: checkbox field type. 

Image of code snippit

Using the Properties in Queries

Now that you have your very own result item, you are now able to use these properties directly within your search queries, however be sure that the index does actually contain your field :). You are able to construct a Sitecore content search predicate using our NewsResultItem like so: 

 

Field Type Converters

There is a whole host of converters that come with the Sitecore content search and they are all located under the Sitecore.ContentSearch.Coverters namespace, apart from the Boolean converter which is located under Sitecore.ContentSearch.LuceneProvider.Converters.

You can find the type converts section within the following config files, depending on what provider you are using:

1) Sitecore.ContentSearch.Lucene.DefaultIndexConfiguration.config

2) Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config

About the author

3chillies

Unlimited possibilities

3chillies

Get in touch today