Deep dive: cross-core join functionquery with parameter de-referencing

Cross-core join functionquery could use a local qf parameter for parameter dereferencing:

I’m using the same cross-core join functionquery quite extensively in my use case: for facet queries, filter queries and field aliasing. I tried to de-refence the join query syntax with local parameters to enable clean client requests, but this seemed not so simple and only possible via introducing a 2nd local parameter…

The regular join query syntax with dereferenced parameter: {!join fromIndex=core2 from=core2_a to=core1_a v=$qq}

This is always parsed to: {!join fromIndex=core2 from=core2_a to=core1_a}core1_df:<value of $qq>

The problem is that the df parameter (core1_df) is set a field in core1 for the default query field in the main query clause (for the regular searches) and doesn’t exist in the core2. Hence this causes a ‘field <df> not found’ error.

The “workaround” that I found, is to define the 2nd local parameter as a query (thanks to SOLR-2128 <https://issues.apache.org/jira/browse/SOLR-2128>):

{!join fromIndex=core2 from=core2_a to=core1_a v=$jqq}

with: jqq={!df=core2_df v=$qq} or jqq={!term f=core2_df v=$qq}

This was the only approach that I found where the join was parsed/executed as I wanted in the facet queries, filter queries and field aliasing. So this solved my issue.

So, unless there is a syntax that I overlooked (in that case, thanks for pointing this out), I think it would make sense to add a df and/or qf local parameter to the cross core join query.
This because, in a typical use case, the joined core2 will have a completely different schema than the main core1. So my suggestion to Solr developers is to enable a syntax as: {!join fromIndex=core2 from=core2_a qf=core2_df to=core1_a v=$qq}

Related Posts

Leave a comment