Closed (fixed)
Project:
Search API Solr
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
26 Mar 2013 at 16:21 UTC
Updated:
24 Apr 2016 at 18:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
Claire Hernandez commentedI am too really interested by the answer to this question. Dear mainteners, does a patch with what Julian said would help and would be integrated ?
Comment #2
_wdm_ commentedIt looks like the wrong escaping method has been used, the attached patch swaps SearchApiSolrConnectionInterface::phrase for SearchApiSolrConnectionInterface::escapePhrase.
This looks like a new option is required to let the config pick the escaping method.
Comment #3
drunken monkeyJust use the "Direct query" parse mode (in the page settings, or in Views under Advanced > Query settings) if you want to use Solr's query syntax. Otherwise, entered words will always be searched as they are entered (except quotes).
Comment #4
kenorb commentedMy similar issue:
#2085257: Issue with direct query, double quotes and exclusionary search (and-or)
Comment #5
drunken monkeyComment #7
lex0r commentedI tried to use direct query mode, but it doesn't affect anything - the keys are anyway passed through flattenKeys and ::phrase. The only place where direct mode is used is here:
search_api/includes/query.inc:
Although keys are returned as is, no more direct mode checks are made further in the call stack to consider this, and keys are just escaped using "phrase" method.
So, the following code will not work even in direct mode:
If all the above is not just my misunderstanding this is not a support request but a bug.
Comment #8
lex0r commentedI'm actually inclined to think this is a bug, since search_api_solr which is in charge of sending server-specific request just ignores the parse mode. Please see the patch and let me know if all this discussion does make any sense :)
Comment #9
kenorb commentedComment #10
drunken monkeyThe "parse mode" is not made to be followed by the backend plugins, it's just there for the query to parse the keys. The way the query "signals" to the backend whether it should take the keywords as-is or pre-process them (i.e., use
flattenKeys()andphrase(), in the case of Solr) is by letting the keywords be a string or an array. In the former case, they should be handed unprocessed to the search engine (if possible), in the latter case they should be escaped.And, if you look at the Solr backend plugin, you'll see that we do check for
is_array($keys)before callingflattenKeys(). This is definitely working correctly.It seems there is some complication on your system for this, maybe something else altering the keys, or adding their own.
To test, use something like the following:
This will circumvent any preprocessing that might otherwise occur.
Comment #11
lex0r commentedHowever, it is backend that parses the query, not only the query class:
What is the code above if not original query parsing into a string having Solr query syntax?
For those who still want to have AND/OR handled by backend class, and use keys in array form, check the updated #8 patch with a bug fix attached.
Comment #12
kenorb commentedComment #13
drunken monkeyThat's not parsing, since it's already receiving a structured array of keywords. "Formatting" maybe.
But that's semantics – my point that the parse mode is only for the query still stands.
But sure, if someone wants it differently, they can just use your patch.