I'm using SOLR 9.2.1

I have a parent document with a couple of subdocuments, something like this:

   {

   id: "1",

   contexts: [

        {

           id: "CTX1",

           context: "hola"

       },{

           id: "CTX2",

           context: "adios"

      }

   ]

   }

When I try to execute this query:

   ({!parent which="*:* -_nest_path_:*"}(context:(hol? AND h?la)) AND
   {!parent which="*:* -_nest_path_:*"}(context:(adios)))

I expected to receive document with id 1 as a response, but instead i receive this syntax error:

org.apache.solr.search.SyntaxError: Cannot parse '(context:(hol?': Encountered \"<EOF>\" at line 1, column 14.\nWas expecting one of:\n    <AND> ...\n    <OR> ...\n    <NOT> ...\n    \"+\" ...\n    \"-\" ...\n <BAREOPER> ...\n    \"(\" ...\n    \")\" ...\n    \"*\" ...\n    \"^\" ...\n    <QUOTED> ...\n    <TERM> ...\n    <FUZZY_SLOP> ...\n    <PREFIXTERM> ...\n <WILDTERM> ...\n    <REGEXPTERM> ...\n    \"[\" ...\n    \"{\" ...\n    <LPARAMS> ...\n    \"filter(\" ...\n    <NUMBER> ...\n


It explicitly says that found and <EOF> but that's not true, it is followed by and AND which is one of the expected values.

As further information, I've been able to narrow the query to the point where this clause works but gives an empty result:

{!parent which="*:* -_nest_path_:*"}context:(hola) AND id:1

But this one throws the mentioned syntax error:

id:1 AND {!parent which="*:* -_nest_path_:*"}context:(hola)

After reading the documentation more thoroughly I think I found the explanation of why the first query is returning an empty result here: https://solr.apache.org/guide/8_0/the-standard-query-parser.html

It says:

   /Gotcha: Be careful not to start your query with {! at the very
   beginning, which changes the parsing of the entire query string,
   which may not be what you want if there are additional clauses./

So the first query is using the block join query parser for everything and effectively the second clause after the AND is searching for id with value 1 in the children not the parent so the condition is never met and nothing is returned.

The second one instead is using the standard parser for the first clause and the block join query parser for the second. In fact removing the

Is this a bug or am I misinterpreting how different query parsers can be combined in a query?

--


     IgorBlanco

Director desarrollo a medida | Neurrirako garapenen zuzendaria

Binovo IT Human Project




        943 569 206 <tel:943 569 206> | 690229375 <tel:690229375>

        [email protected] <mailto:[email protected]>

        binovo.es <//binovo.es>

        Astigarragako Bidea, 2 - 2º izda. Oficina 10-11, 20180 Oiartzun




        
youtube <https://www.youtube.com/user/CANALBINOVO/>       
        linkedin <https://www.linkedin.com/company/binovo-it-human-project/>    
  

Reply via email to