marcel_g marcel_g - 19 days ago 9
JSON Question

Kentico Smart Search Index - any way to read it with the API?

We need to get a search box autocomplete working based on Kentico search indexes, but half the site is in the CMS app pages, and half is in MVC. So the autocomplete webpart works on the CMS app pages, but not the MVC ones.

An option we're exploring is to use the Twitter Typeahead js library in both sides of the site, which requires the search terms to be in a json file.

So we'd like to be able to load the search index terms via the Kentico API and then write that out to a json file.

The SearchIndexInfo object doesn't seem to have a way to get the index's terms that it writes out to the index files.

Update

For clarification: We can do the search via the API, but the searchresultitems only return with the title and content fields, and they do not contain all the search terms that are stored in the index files.

For instance, a search index for a custom page type might build the index based on the DocumentName, Description, Location, City, Company Name, DesignCategory fields. All of those will be stored in the index somewhere, so how do we read the terms that are stored in the index?

Not just the results, which would only have DocumentName(title) and Description (content).

We're basically trying to convert the search index files into a json representation, not the search results.

Of course, if the SmartSearchDialog webpart just does its predictive search on only the title and content fields, then we would just go with that, but I believe the SmartSearchDialog does an actual search does it not?

thanks

Answer

Roman's answer in the comments doesn't look like it would work, and in thinking about it some more we were perhaps trying to do something too complicated and weren't asking the right question maybe.

Instead of trying to replicate the search index in json for use by the twitter typeahead autocomplete, perhaps a better way to do it is to keep it simpler and just use the search results' title and content fields.

Then, in order to get additional fields into the content field of the search results ( such as project location ) we can then customize the search building code (CMSLoaderAttribute) to add the extra fields into the SearchDocument's Content field.

Comments