Use the Extended DisMax query parser and support all queries. #142
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, SolrSearch is using the standard query parser. This parser has strict syntax requirements, so it is very easy to create a query that it can't process. One example is specifying a single double-quote, as noted in #137. SolrSearch made a few attempts at fixing some of these syntax issues by replacing colons with spaces, and removing square-brackets from query strings. Those changes can present their own issues, such as preventing users from searching against a specific field.
Solr also provides a query parser known as Extended DisMax or eDisMax. This parser is much more tolerant of non-standard syntax, automatically escaping characters as necessary:
https://cwiki.apache.org/confluence/display/solr/The+Extended+DisMax+Query+Parser
This pull request makes all queries use the eDisMax query parser by adding
{!edismax}
to the start of the query string on line 142. This seems like the simplest way to improve query parsing for plugin users, but does limit changing the parser in the future to changing that line of code.An alternative change could be made to the
solrconfig.xml
file as discussed in #139. This would require plugin users to alter or replace the file copied to their Solr installation, and reload the core in Solr. But, it would allow changes to the query parser without having to edit the plugin's code.Beyond enabling the eDisMax query parser, this pull request also makes changes to how query strings are formed:
title:"search string"
.