Accessing Search in MVC widget

Posted by Community Admin on 04-Aug-2018 19:03

Accessing Search in MVC widget

All Replies

Posted by Community Admin on 08-May-2017 00:00

I have an MVC widget that shows a list of blog posts and I would like to also search using this widget in place of the built in search widget. A search index has created for blog posts and I followed the code from this article: knowledgebase.progress.com/.../How-to-search-programmatically-in-Sitefinity

The result is coming back with a hit count of 39 and the IResultSet in the SearchHelper has a collection of items in it. However, when the Helper returns result.SetContentLinks() the result is an empty list.

Attached are a few screenshots of different points:
InitialResultObject.png - Before calling SetContentLinks I am able to drill down into the object and see the list and details of each search result.

CallingSetContentLinks.png - After calling SetContentLinks, drilling down into the Results View of the object it shows an empty result. Sometimes I do get an "Object is not set to an instance of an object" error as well but I don't know what object it is referring to.

This is the code calling the SearchHelper

var queryBuilder = ObjectFactory.Resolve<IQueryBuilder>();
var searchService = ServiceBus.ResolveService<ISearchService>();
string[] searchFields = "Title", "Content" ;
var hitCount = 0;

var result = SearchHelper.Search(searchService, queryBuilder, "searchTerm" , searchFields, "myIndex", null, 0,10, null, null, out hitCount);

 

Any thoughts would be appreciated. Thanks!

~Susan

This thread is closed