Reputation: 1
We are implementing Smart Search in Kentico 13. In our initial we had enabled the search feature, followed by adding local indexes (I added a local index with name "DefaultSearchIndex"). For the indexes we have set the path to a page with sub pages so that search results are considered from sub pages. After doing the configuration when I search from the admin panel under Local Indexes>DefaultSearchIndex>Search preview, I get the correct result.
Now, the issue I am facing is that I want to use the same index at controller end to return a custom view. Here I used the code provided in documentation also shown below
` IEnumerable<string> searchIndexes = new List<string> { "DefaultSearchIndex" };
int pageNumber = 1;
int pageSize = 1000;
UserInfo searchUser = MembershipContext.AuthenticatedUser;
string cultureCode = "en-us";
/* Indicates whether the search service uses site default language version of pages as a replacement
for pages that are not translated into the language specified by 'cultureCode' */
bool combineWithDefaultCulture = true;
// Prepares a 'SearchParameters' object to search through indexes of the 'Pages' type
SearchParameters searchParameters = SearchParameters.PrepareForPages(searchQuery, searchIndexes, pageNumber, pageSize, searchUser, cultureCode, combineWithDefaultCulture);
searchParameters.Path = searchPath.Replace("/", "") + "/%";
// Searches the specified indexes
SearchResult searchResult = SearchHelper.Search(searchParameters);`
You can see that I have added the index but when I call this API, this is not returning any results using the index name of the local index.
Secondly, when I rename the Local Index to "Search", this returns the results but for all the nodes, that is it is not considering the selected path in the Indexed content.
I was expecting correct results from the selected path.
Upvotes: 0
Views: 192
Reputation: 1529
Try hardcoding the exact path you want in searchParameters.Path
with using the first index you mention.
searchParameters.Path = "/my-path/%";
That should validate if filtering down the results of the index by path works or not.
Upvotes: 0