solrlucenesolr5solr8

local param not working in solr 8 but working in solr 5


I am migrating from solr 5.5 to solr 8. Query for solr 5.5 looks like -

qt=/dismax
product_fields_Ref1=product_concept^279841
sku_and_product_fields_Ref1=silhouette_concept^234256 $product_fields_Ref1
product_phrase_Ref2=pant
concept_with_synonyms_ref1=({!edismax2 qf=$sku_and_product_fields_Ref1     v=$product_phrase_Ref2})
top_concept_query_ref= (+({!maxscore v=$concept_with_synonyms_ref1}) ) 
productQueryRef3=+(+({!query v=$cq})) +( ({!maxscore v=$top_concept_query_ref}) ) 
sq=+{!lucene v=$productQueryRef3}
q={!parent tag=top which=$pq score=max v=$sq}

But is giving error on solr 8.0 with error -

Error from server at http://localhost:8080/products: org.apache.solr.search.SyntaxError: Query Field '$product_fields_Ref1' is not a valid field name

If I modify query like this (remove the variable product_fields_Ref1 and append the value directly in sku_and_product_fields_Ref1) -

qt=/dismax
sku_and_product_fields_Ref1=silhouette_concept^234256 product_concept^279841
product_phrase_Ref2=pant
concept_with_synonyms_ref1=({!edismax2 qf=$sku_and_product_fields_Ref1     v=$product_phrase_Ref2})
top_concept_query_ref= (+({!maxscore v=$concept_with_synonyms_ref1}) ) 
productQueryRef3=+(+({!query v=$cq})) +( ({!maxscore v=$top_concept_query_ref}) ) 
sq=+{!lucene v=$productQueryRef3}
q={!parent tag=top which=$pq score=max v=$sq}

Problem is I can not modify this query since the value of param "product_fields_Ref1" are being compiled from a large number of places. I am using defType=dismax only. Can any one guide what needs to be fixed?


Solution

  • I went through the source code of "org.apache.solr.search.ExtendedDismaxQParser" and found out the is a new validation check added which DOES NOT allow local parameter in qf field edismax parser (this check has been introduced starting solr 8.0.0).

    Check works like this -

    any parameter coming in qf MUST match a field in schema (I am not using schema-less mode) of the core. method is

    validateQueryFields(up);

    This executes in

    public Query parse() throws SyntaxError { ... }

    of

    org.apache.solr.search.ExtendedDismaxQParser

    I got this working by creating my own custom parser and removed this validator after overriding the parse() method.