I want to search string which contains special characters using Azure Search .NET SDK.
I've tried escaping every special character, tried using full query syntax
and tried wildcards, nothing worked as expected.
Here is the method:
public virtual async Task<SearchResultDto<T>> Search(string query, SearchOptionsInput searchOptionsInput)
{
if (!_azureOptions.IsEnabled)
{
return null;
}
var searchIndexClient = GetSearchIndexClientForGivenType();
var searchParameters = _objectMapper.Map<SearchParameters>(searchOptionsInput);
searchParameters.QueryType = QueryType.Full;
var searchResult = await searchIndexClient.Documents.SearchAsync<T>(query, searchParameters);
return new SearchResultDto<T>
{
Count = searchResult.Count,
Results = searchResult.Results.Select(r => r.Document).ToList(),
FacetResults = searchResult.Facets,
};
}
I have document with Name
field set to $@!Q$@!
. When I write it in query and escape exclamation mark (like $@\!Q$@\!
) I get proper result. But when I delete last !
and write *
wildcard in query instead I get no results. Without any sign there's no result aswell.
Is there a way to properly write special characters so search will return results on match eg. when I write $@\!*
?