Hello,

I am using Solr 5.4.0, one collection, multiple shards with replication.
Sample documents:
{
"item_id": "30d1e667",
"date": "2014-01-01",
"position": "5",
"description": "automobile license plate holder"
}

{
"item_id": "3cf18028",
"date": "2013-01-01",
"position": "23",
"description": "dinner plate"
}

{
"item_id": "be1b2643",
"date": "2013-06-01",
"position": "21",
"description": "ceramic plate"
}


The client sends 2 queries like this:
(1) /select?q=item_id:30d1e667&fl=position
(2) /select?q=plate&query_position=5&boost=custom_function($query_position,
$position)&fl=item_id,date,description

The idea is, we have an application-specific data field "position" which we
use to compare 2 items. The client looks up a particular item by item_id,
gets the position data, then sends it back in the 2nd query to influence
the ranking of items when performing a text search for "plate". Our
custom_function is app-specific and may for example derive the boost from
the difference of query_position and document's position.

My need is: I want to combine these into one query, so the client will only
have to send something like:

/select?query_item_id=30d1e667&query_text=plate&q={… use of Solr nested
queries, boost functions etc …}&fl=item_id,date,description

I want this to be one request so that both queries are executed against the
same searcher (because index updates may change the position values) and so
the details of using the "position" field are abstracted from the client.

I have considered the query(subquery,default) function. This is close, but
not exactly what I need because it returns the subquery score, not document
values.

The join query parser is also close to what I need, but I can't see how to
use it to direct the results of a subquery into the boost function of
another.

So how can I, in a single Solr request, extract a value from the result
document of one subquery, and pass that value into a boost function for a
2nd query, all using the same underlying searcher? If it's not possible
with existing nested/sub-queries, then should I explore writing a custom
SearchComponent, QParser, or some other plugin?

thanks,
Ed

Reply via email to