Time for action – executing a nested Edismax query

Using the defType=edismax parameter, it's possible to combine the usage of Edismax and Lucene together at the same time. Moreover, we can execute more restrictive queries nested one into another by performing the following steps:

  1. In the following example, we ask for documents containing the term painting in the abstract field, and then we define a nested query using the Edismax query parser ({!dismax ...}) as follows:
    >> curl -X GET 'http://localhost:8983/solr/paintings/select?q=abstract:painting%20AND%20_query_:%22{!dismax%20qf=artist^2%20qf=abstract%20pf=abstract^3%20mm=3%20v=$qq}%22&fl=title%20artist&wt=json&qq=giraffe%20dali%20%22female%20figure%22%20vermeer'
    
  2. Note how this example looks very ugly at first, due to nested elements and HTTP encoding, but now we will see that it's not so complicated as it may seem.
  3. Even if we use cURL for transcribing examples, I suggest you to try to reproduce the same example by inserting the parameter values on the web interface or on your browser's console, as it's always useful to have multiple and different access to read the data.

What just happened?

If you look carefully at the parameter sequence of this simple nested query, you will find that the most interesting part is the following code:

q=abstract:painting 
AND 
_query_:"{!dismax qf=artist^2 qf=abstract pf=abstract^3 mm=3 v=$qq}"
qq=giraffe dali "female figure" vermeer

We are actually performing two different kinds of queries and then combining them with an AND condition, so that they have to be verified at the same time. Please consider that the qq parameter name cannot be changed at the moment, and it's used to define what you can see as a sort of local variable, useful for writing the nested query text in a clearer form.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.17.140