Hello Csaba Hári,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
I understand that you would like how to handle search.ismatchscoring special characters.
When using search.ismatchscoring in Azure Search, handling special characters like dots (.
) and slashes (/
) can sometimes cause unexpected behavior. Below are practical strategies and examples to resolve such issues effectively.
- The full Lucene query syntax allows you to control how special characters are processed. You can enable it by setting the
queryType
parameter to'full'
. This is an example:
(Product eq 'CapitalStructure') and (search.ismatchscoring('"SEC (10-Q) : Acutus Medical, Inc.*"', 'Title', 'full', 'all'))
This approach ensures that special characters like colons (:
) and parentheses ((
and )
) are treated as part of the search term.
- Custom analyzers allow you to define specific rules for tokenizing and indexing text. By configuring an analyzer to handle special characters, you can ensure consistent search behavior. For instance:
- Use a custom tokenizer to split tokens only at desired characters.
- Apply filters to preserve or remove specific symbols.
Use this link in Azure Search analyzer documentation. - https://learn.microsoft.com/en-us/azure/search/search-analyzers) for detailed guidance on creating custom analyzers
- In Lucene syntax, special characters (e.g.,
+
,-
,&&
,||
,!
,(
,)
,{
,}
,[
,]
,^
,"
,~
,*
,?
,:
) can be escaped using a backslash (\
). For example:
search.ismatchscoring('"SEC \(10\-Q\) : Acutus Medical, Inc."', 'Title', 'full', 'all')
This ensures that the query treats special characters as literal parts of the search term.
- If the query allows, remove unnecessary special characters to simplify your input. For instance:
- Original:
"SEC (10-Q) : Acutus Medical, Inc."
- Simplified:
"SEC 10-Q Acutus Medical Inc"
This approach minimizes the risk of misinterpretation by the search engine.
- If you're searching for text that begins with a specific pattern, use a prefix query:
(Product eq 'CapitalStructure') and (search.ismatchscoring('"SEC (10-Q) : Acutus Medical, Inc*"', 'Title', 'full', 'all'))
The asterisk (*
) acts as a wildcard to match any characters following the prefix.
For additional examples and reading use this link: https://learn.microsoft.com/en-us/azure/search/search-query-odata-full-text-search-functions
I hope this is helpful! Do not hesitate to let me know if you have any other questions.
Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.