Try our conversational search powered by Generative AI!

Using Highlights with wildcard search query

Vote:
 

Hi there!


I've a problem using Highlights with a wildcard search query. I'm using the following code:

var searchResult = SearchClient.Instance.Search<BasePage>()
 .For(searchTerm, query =>
                {
                    query.Query = searchTerm + "*";
                })
 .WithHighlight(w => w.SearchResultText, a => a.NumberOfFragments = 20).GetContentResult();

 

If I perform the above code and look in the variable searchResult: searchResults.SearchResult.Hits.Highlightsthe Highlight array is empty for all results. If I replace the wildcard search query with a normal search like:

var searchResult = SearchClient.Instance.Search<BasePage>()
.For(searchTerm)
.WithHighlight(w => w.SearchResultText, a => a.NumberOfFragments = 20).GetContentResult();

    

If I perform the above code then the Highlight array is filled with values.

Can someone tell me how I can use a wildcard search and use the Highlight functionality? Is it also possible with Highlights to just return values from the search result without specifying the fields where the Highlights are set?

Thanks!

    

#83188
Mar 27, 2014 11:58
Vote:
 

Hi,

Highlighting is not supported for wildcard queries and no you have to specify the fields to highlight when issuing the query.

Best Regards,
Henrik

#83201
Mar 27, 2014 13:20
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.