How to search for special characters in XWiki Solr?

Last modified by Nikita Petrenko on 2025/05/02

For example, users must find pages containing specific symbols (like§##). The particular search syntax will be §\~#\~#, but the expression itself will not provide sufficient results because Solr does not support such syntax. The search query needs to be updated to find the desired pages, for that user needs to use a combination with a word (test §\~#\~#).

Additional information:

  • Escaping Special Characters in Solr:

Solr’s query parser uses special characters (like \, ~, *, etc) with specific query processing functions. When a user wants to search for these characters as literals, they need to be escaped using a backslash (\). More detailed information about how to escape these characters can be found in the Solr documentation Escaping Special Characters.

  • Using Tilde for Fuzzy Searches:

The tilde (~ ) symbol is commonly used in Solr queries for fuzzy searches. Fuzzy searches discover terms that are similar to a specified term without necessarily being an exact match. To perform a fuzzy search, use the tilde symbol at the end of a single-word term. For example, to search for a term similar in spelling to "roam," use the fuzzy search (roam~1). For more details, check Fuzzy Searches.

  • XWiki Default Search Behavior:

By default, XWiki's Solr search configuration returns results for search queries that contain more than 2 characters when searching by page title and content. You can view and modify the settings related to search suggestions and query behavior via the page XWiki.SearchSuggestConfig. For more check, XWiki documentation Solr Search Application.

 

Get Connected