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 Rodrigo Rezende <rc...@gmail.com> on 2010/07/15 17:32:39 UTC

Nested Function Query Syntax

Hello,

I am trying to use function nested query syntax with solr 1.4.1, but I
am not sure if I am doing in right way:

I try this query and I get all documents which score is 12

http://localhost:8983/solr/articles.0/select/?q={!func}product(3,4)&fl=Document.title,score,&debugQuery=on

Using the same syntax, for nested query, I get an error

http://localhost:8983/solr/articles.0/select/?q={!func}query(hello)&fl=Document.title,score,&debugQuery=on

org.apache.lucene.queryParser.ParseException: Nested function query
must use $param or {!v=value} forms. got 'query(hello)'

Thanks,

Rodrigo.

Re: Nested Function Query Syntax

Posted by Rodrigo Rezende <rc...@gmail.com>.
Thank you, that works fine!

On Thu, Jul 15, 2010 at 2:01 PM, Yonik Seeley
<yo...@lucidimagination.com> wrote:
> On Thu, Jul 15, 2010 at 12:49 PM, Rodrigo Rezende <rc...@gmail.com> wrote:
>> Yeah, it is redundant, but I am using that to use the solr query
>> response as input of a plugin function:
>>
>> http://localhost:8983/solr/articles.0/select/?q={!func}myFunction(query({!query
>> v='the query string here'}))
>
> This might be easier (requires no escaping of  the query string):
> http://localhost:8983/solr/articles.0/select/?q={!func}myFunction(query($qq))&qq=the
> query string here
>
> -Yonik
> http://www.lucidimagination.com
>

Re: Nested Function Query Syntax

Posted by Yonik Seeley <yo...@lucidimagination.com>.
On Thu, Jul 15, 2010 at 12:49 PM, Rodrigo Rezende <rc...@gmail.com> wrote:
> Yeah, it is redundant, but I am using that to use the solr query
> response as input of a plugin function:
>
> http://localhost:8983/solr/articles.0/select/?q={!func}myFunction(query({!query
> v='the query string here'}))

This might be easier (requires no escaping of  the query string):
http://localhost:8983/solr/articles.0/select/?q={!func}myFunction(query($qq))&qq=the
query string here

-Yonik
http://www.lucidimagination.com

Re: Nested Function Query Syntax

Posted by Rodrigo Rezende <rc...@gmail.com>.
Yeah, it is redundant, but I am using that to use the solr query
response as input of a plugin function:

http://localhost:8983/solr/articles.0/select/?q={!func}myFunction(query({!query
v='the query string here'}))

So in myFunction I can take the query results, with the score, and
write my custom sort/re-scorer.

Is that the best way?


On Thu, Jul 15, 2010 at 1:16 PM, Yonik Seeley
<yo...@lucidimagination.com> wrote:
> On Thu, Jul 15, 2010 at 11:51 AM, Rodrigo Rezende <rc...@gmail.com> wrote:
>> I solved the problem.
>> The correct syntax is:
>>
>> http://localhost:8983/solr/articles.0/select/?q={!func}query({!query
>> v='hello'})&fl=Document.title,score,&debugQuery=on
>
> query() causes a new QParser to be created.  so does {!query}... so
> using both is redundant.
> If you want an embedded lucene query, then you could do
>
> query({!lucene v='hello'})
>  OR
> query({!lucene v=$qq})  &  qq=hello
>  OR, since lucene is the default query type
> query($qq)  &  qq=hello
>
> -Yonik
> http://www.lucidimagination.com
>

Re: Nested Function Query Syntax

Posted by Yonik Seeley <yo...@lucidimagination.com>.
On Thu, Jul 15, 2010 at 11:51 AM, Rodrigo Rezende <rc...@gmail.com> wrote:
> I solved the problem.
> The correct syntax is:
>
> http://localhost:8983/solr/articles.0/select/?q={!func}query({!query
> v='hello'})&fl=Document.title,score,&debugQuery=on

query() causes a new QParser to be created.  so does {!query}... so
using both is redundant.
If you want an embedded lucene query, then you could do

query({!lucene v='hello'})
  OR
query({!lucene v=$qq})  &  qq=hello
  OR, since lucene is the default query type
query($qq)  &  qq=hello

-Yonik
http://www.lucidimagination.com

Re: Nested Function Query Syntax

Posted by Rodrigo Rezende <rc...@gmail.com>.
I solved the problem.
The correct syntax is:

http://localhost:8983/solr/articles.0/select/?q={!func}query({!query
v='hello'})&fl=Document.title,score,&debugQuery=on

Rodrigo




On Thu, Jul 15, 2010 at 12:32 PM, Rodrigo Rezende <rc...@gmail.com> wrote:
> Hello,
>
> I am trying to use function nested query syntax with solr 1.4.1, but I
> am not sure if I am doing in right way:
>
> I try this query and I get all documents which score is 12
>
> http://localhost:8983/solr/articles.0/select/?q={!func}product(3,4)&fl=Document.title,score,&debugQuery=on
>
> Using the same syntax, for nested query, I get an error
>
> http://localhost:8983/solr/articles.0/select/?q={!func}query(hello)&fl=Document.title,score,&debugQuery=on
>
> org.apache.lucene.queryParser.ParseException: Nested function query
> must use $param or {!v=value} forms. got 'query(hello)'
>
> Thanks,
>
> Rodrigo.
>