Expose search fields to Search Manager
I think SearchManger is searching only in Title, Description,Content. How can I add more search fields to to SearchManager. I know if I use search results widget, I could go into advanced section and could add search fields. But I need to use Search Manager. How can I do this with SearchManager.
Hi,
I am also working on the same. is there any way to achieve this? Aside from searchManager there are also ISearchSevice and ISearchQueryBuilder. should any of these be used? I don't want to build the index but to do only searching part using the index built in sitefinity administration.
Regards,
Chaitanya
Hello Chaitanya,
You could take a look on this forum post for extending search indexing with keywords.
If this do not cover your need, could you please give us more details about the scenario you have and the Sitefinity version you are using.
Regards,
Svetoslav Manchev
Telerik
Thanks for the reply Svetoslav,
I am using Sitefinity version 6.1.4700. the post you have referred shows how to extend the built in Sitefinity Search Widget to include the keywords. Correct me if I’m wrong, steps for that are as below.
1. Go to search indexes in administration. Create an index with scope for the needed content, add other fields in advanced section separated by comma.
2. Drop search widget on a page, select index to be used and page where search results widget is present. In search results widget add fields(comma separated) in searchfields from advanced options.
I have implemented above and it works fine. For eg in case of movies I am getting the results by title, actor, director or whichever fields I add for index and search.
What I want to implement is a custom search on the index made by using the 1st step in above mentioned process. The need for the custom search is I want search with autocomplete and different way of handling the results.
I am using ajax calls to query the indexed content on runtime and giving autocomplete options using jquery autocomplete. For search purpose I used SearchManagers Find method. Suppose I have to find movie batman, I get results when I search for bat(I added * with QueryString for wildcard search) now as the Director field is also indexed I should get Batman in results when I search for Christophe (director of that movie). But my problem is I don’t get results while searching in other fields like director in the example
Your advice on this would be helpful.
Regards,
Chaitanya.
Hello Chaitanya,
In order to use in the search index custom fields created in your module (for example: Movie Author), you need to add this additional custom fields on both places:
1) Administration > Search indexes > <your index> > Advanced > Additional fields for indexing
(Note that these fields should be of type short or long text)
and
2) Search result page > Search results Widget > Edit > Advanced > SearchFields
(separated by comma)
I have tested it on my end and it works fine.
What I have tested: I have created a New module with content item fields: Movie title, author, etc. and add the additional fields as described above. The search results returns the movie searched by author also (here you could see how it works).
Regards,
Svetoslav Manchev
Telerik
Hello Svetoslav,
I have achieved what you said. but that is not I need. I want a custom search widget. for getting the results I have used following code.
searchTerm and catalougeName in code below are passes by other function
string searchTerm;
string catalogueName;
var searchManager = SearchManager.GetManager(null);
if(searchManager.SearchIndexExists("testindex"))
var searchQuery = sting.Format("0*", searchTerm); // * added for wildcard search
var results = searchManager.Find(catalogueName, searchQuery);
else
-- exception code
in above code example results is IResultset from which I can separate the different results but the thing is it does not returns search from all fields. I want searchManager to search in all fields ie added by me to the index(for eg author or director)
Regards,
Chaitanya
Hello Chaitanya,
In order to extending Sitefinity search you could check these blog posts:
- Extending Sitefinity Search and searching by category
- Adding Custom Search Results into Sitefinity Search Results Widget
Regards,
Svetoslav Manchev
Telerik