5

I just want to combine block join query and main-query with edismax-parser as I do it for solr < 7.2

berlin OR _query_:"{!parent which=type:book}page_content:berlin"

But edismax cannot be the default-Parser for this purpose any more(s. https://issues.apache.org/jira/browse/SOLR-11501)

So it works with lucene-QueryParser for querying parents:

q={!parent which="type:book"}{!edismax qf='page_content' v='berlin'}

it still works for adding main query like

q=title:berlin* AND {!parent which="type:book"}{!edismax qf='page_content' v='berlin'}

but when I try

q={!edismax qf='title' v='berlin'} OR {!parent which="type:book"}{!edismax qf='page_content' v='berlin'}

only the first part of the query is evaluated.

My docs are:

<add>
  <doc>
    <field name="id">1</field>
    <field name="type">book</field>
    <field name="title">Book about Berlin</field>
    <field name="pages">
    <doc>
      <field name="id">11</field>
      <field name="type">page</field>
      <field name="page_content">berlin in winter</field>
    </doc>
    <doc>
      <field name="id">12</field>
      <field name="type">page</field>
      <field name="page_content">berlin in spring</field>
    </doc>
    <doc>
      <field name="id">13</field>
      <field name="type">page</field>
      <field name="page_content">berlin in summer</field>
    </doc>
  </field>
 </doc>
 <doc>
    <field name="id">2</field>
    <field name="type">book</field>
    <field name="title">Big book about Tokio</field>
    <field name="pages">
    <doc>
      <field name="id">21</field>
      <field name="type">page</field>
      <field name="page_content">tokio in winter</field>
    </doc>
    <doc>
      <field name="id">22</field>
      <field name="type">page</field>
      <field name="page_content">tokio in spring</field>
    </doc>
    <doc>
      <field name="id">23</field>
      <field name="type">page</field>
      <field name="page_content">tokio in summer</field>
    </doc>
  </field>
 </doc>
</add>

Does anybody have the same problem?

Thanks a lot!

katja
  • 63
  • 5

1 Answers1

6

That is because, as of Solr 7.3, the defaults regarding searchable fields for edismax actually prohibits the use of embedded query.

Fortunately, this behavior can be managed with uf parameter.

uf : Specifies which schema fields the end user is allowed to explicitly query and to toggle whether embedded Solr queries are supported. This parameter supports wildcards. Multiple fields must be separated by a space.

The default is to allow all fields and no embedded Solr queries, equivalent to uf=* -_query_.

Set uf=* _query_ to allow embedded queries.

I tested it on Solr 7.7.1, it works but I had to wrap the embedded query in double quotes otherwise the whole query fails returning 0 result without any notice.

This query should work :

defType=edismax&uf=* _query_&q=title:berlin* OR "{!parent which="type:book"}page_content:berlin"

Note : There are examples in documentation for Solr < 7.3 mentioning a comma-separated list in uf parameter, but the expected separator is definitely a space.

For those who are not using edismax you will have to set luceneMatchVersion=7.1.0 for full backward compatibility.

EricLavault
  • 12,130
  • 3
  • 23
  • 45
  • Thanks a lot Eric, but as far as I understood and tested it is not allowed for solr > 7.1 to use any other parser when edismax is a default one ( SOLR-11501). Up to 7.2 it works – katja Apr 19 '19 at 13:00
  • I cannot try it now, but definitely it doesn’t work if I define edismax as default parser in solrconfig what schould be the same as to put it in url-param – katja Apr 19 '19 at 13:08
  • @katja ... damn ! Meanwhile I realized that the schema fields for edismax actually *prohibits* the use of *_query_* so you have to explicitly set `uf=*,_query_` for this to work (it should work inline as well). Also you can still set `luceneMatchVersion=7.1.0` for full backward compatibility.. I've no time to dig it right now but I will make some test in the weekend and update the answer accordingly. – EricLavault Apr 19 '19 at 14:50
  • Thanks @Eric, it works defType=edismax&uf=* _query_&q=book AND _query_:"{!parent which=type:book}page_content:berlin" – katja Apr 23 '19 at 12:08
  • Cool ! Please consider reading [this](https://stackoverflow.com/help/someone-answers), thank you for your feedbacks – EricLavault Apr 23 '19 at 12:19