You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Anand Chandrashekar <an...@gmail.com> on 2016/04/06 12:01:33 UTC

Solr 5.5.0: SearchHandler: Appending a Join query

Greetings.

1) A join query creates an array of "q" parameter. For example, the query

http://localhost:8983/solr/gettingstarted/select?q=projectdata%3A%22top+secret+data2%22&q=%7B!join+from=locatorByUser+to=locator%7Dusers=joe

creates the following array elements for the "q" parameter.

[array entry #1] projectdata:"top secret data2"
[array entry #2] {!join from=locatorByUser to=locator}users=joe

2) I would like to enforce the join part as a mandatory parameter with the
"users" field added programmatically. I have extended the search handler,
and am mimicking the array entry # 2 and adding it to the SolrParams.

Pseudocode handleRequestBody:
ModifiableSolrParams modParams=new
ModifiableSolrParams(request.getParams());
modParams.set("q",...);//adding the join (array entry # 2) part and the
original query
request.setParams(modParams);
super.handleRequestBody(request, response);

I am able to mimic the exact array, but the query does not enforce the
join. Seems to only pick the first entry. Any advice/suggestions?

Thanks and regards.
Anand.

Re: Solr 5.5.0: SearchHandler: Appending a Join query

Posted by Alexandre Rafalovitch <ar...@gmail.com>.
I think the easiest thing would be then to put 'q' in the invariant
part and use parameter substitution to get the user query.

Use either
https://cwiki.apache.org/confluence/display/solr/Local+Parameters+in+Queries#LocalParametersinQueries-ParameterDereferencing
or
https://cwiki.apache.org/confluence/display/solr/Parameter+Substitution

Regards,
   Alex.
----
Newsletter and resources for Solr beginners and intermediates:
http://www.solr-start.com/


On 6 April 2016 at 20:01, Anand Chandrashekar <an...@gmail.com> wrote:
> Greetings.
>
> 1) A join query creates an array of "q" parameter. For example, the query
>
> http://localhost:8983/solr/gettingstarted/select?q=projectdata%3A%22top+secret+data2%22&q=%7B!join+from=locatorByUser+to=locator%7Dusers=joe
>
> creates the following array elements for the "q" parameter.
>
> [array entry #1] projectdata:"top secret data2"
> [array entry #2] {!join from=locatorByUser to=locator}users=joe
>
> 2) I would like to enforce the join part as a mandatory parameter with the
> "users" field added programmatically. I have extended the search handler,
> and am mimicking the array entry # 2 and adding it to the SolrParams.
>
> Pseudocode handleRequestBody:
> ModifiableSolrParams modParams=new
> ModifiableSolrParams(request.getParams());
> modParams.set("q",...);//adding the join (array entry # 2) part and the
> original query
> request.setParams(modParams);
> super.handleRequestBody(request, response);
>
> I am able to mimic the exact array, but the query does not enforce the
> join. Seems to only pick the first entry. Any advice/suggestions?
>
> Thanks and regards.
> Anand.

Re: Solr 5.5.0: SearchHandler: Appending a Join query

Posted by Stefan Matheis <ma...@gmail.com>.
Anand,

have a look at the example schema, there is a section that explains
"invariants" which could be one solution to your question.

-Stefan

On Wed, Apr 6, 2016 at 12:01 PM, Anand Chandrashekar
<an...@gmail.com> wrote:
> Greetings.
>
> 1) A join query creates an array of "q" parameter. For example, the query
>
> http://localhost:8983/solr/gettingstarted/select?q=projectdata%3A%22top+secret+data2%22&q=%7B!join+from=locatorByUser+to=locator%7Dusers=joe
>
> creates the following array elements for the "q" parameter.
>
> [array entry #1] projectdata:"top secret data2"
> [array entry #2] {!join from=locatorByUser to=locator}users=joe
>
> 2) I would like to enforce the join part as a mandatory parameter with the
> "users" field added programmatically. I have extended the search handler,
> and am mimicking the array entry # 2 and adding it to the SolrParams.
>
> Pseudocode handleRequestBody:
> ModifiableSolrParams modParams=new
> ModifiableSolrParams(request.getParams());
> modParams.set("q",...);//adding the join (array entry # 2) part and the
> original query
> request.setParams(modParams);
> super.handleRequestBody(request, response);
>
> I am able to mimic the exact array, but the query does not enforce the
> join. Seems to only pick the first entry. Any advice/suggestions?
>
> Thanks and regards.
> Anand.

Re: Solr 5.5.0: SearchHandler: Appending a Join query

Posted by Mikhail Khludnev <mk...@griddynamics.com>.
I suppose q= is singular param doesn't accept multiple values.

On Wed, Apr 6, 2016 at 1:01 PM, Anand Chandrashekar <an...@gmail.com>
wrote:

> Greetings.
>
> 1) A join query creates an array of "q" parameter. For example, the query
>
>
> http://localhost:8983/solr/gettingstarted/select?q=projectdata%3A%22top+secret+data2%22&q=%7B!join+from=locatorByUser+to=locator%7Dusers=joe
>
> creates the following array elements for the "q" parameter.
>
> [array entry #1] projectdata:"top secret data2"
> [array entry #2] {!join from=locatorByUser to=locator}users=joe
>
> 2) I would like to enforce the join part as a mandatory parameter with the
> "users" field added programmatically. I have extended the search handler,
> and am mimicking the array entry # 2 and adding it to the SolrParams.
>
> Pseudocode handleRequestBody:
> ModifiableSolrParams modParams=new
> ModifiableSolrParams(request.getParams());
> modParams.set("q",...);//adding the join (array entry # 2) part and the
> original query
> request.setParams(modParams);
> super.handleRequestBody(request, response);
>
> I am able to mimic the exact array, but the query does not enforce the
> join. Seems to only pick the first entry. Any advice/suggestions?
>
> Thanks and regards.
> Anand.
>



-- 
Sincerely yours
Mikhail Khludnev
Principal Engineer,
Grid Dynamics

<http://www.griddynamics.com>
<mk...@griddynamics.com>