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 Mukundaraman valakumaresan <mu...@8kmiles.com> on 2014/01/07 14:38:30 UTC

Passing variables as values in Query Filter

Hi

The following query executes

http://localhost:8983/solr/collection1/select?wt=json&indent=true&q=locality:A<http://localhost:8983/solr/collection1/select?wt=json&indent=true&q=city:Chennai>
dyar

But I wanted something like the one below which is not working.

http://localhost:8983/solr/collection1/select?wt=json&indent=true&q=locality:$str&str<http://localhost:8983/solr/collection1/select?wt=json&indent=true&q=city:$str&str=Chennai>
="Adyar"

http://localhost:8983/solr/collection1/select?wt=json&indent=true&q=locality:<http://localhost:8983/solr/collection1/select?wt=json&indent=true&q=city:$str&str=Chennai>
getAdjacentLocalities("Adyar")

getAdjacentLocalities() is a custom function implemented.

Any suggestions.

Thanks & Regards
Mukund

Re: Passing variables as values in Query Filter

Posted by Kranti Parisa <kr...@gmail.com>.
did you try this?
q={!func}customfunc($v1)&v1=somevalue&qf=fieldname

more info
http://wiki.apache.org/solr/FunctionQuery


Thanks,
Kranti K. Parisa
http://www.linkedin.com/in/krantiparisa



On Wed, Jan 8, 2014 at 2:22 AM, Mukundaraman valakumaresan <
mukund@8kmiles.com> wrote:

> Hi Ahmet,
>
> Thanks a lot
>
> What I need is this .
> q={!lucene df=city v=$qq}&qq=customfunc(x)
>
> In this case,
> qq=custfunc(x) --> where custfunc is a custom function that has to be
> executed. Instead, how it acts now is, it takes it as a string to search
> if qq  is a number, you will get a NumberFormatException
>
> Thanks & Regards
> Mukund
>
>
>
> On Tue, Jan 7, 2014 at 7:45 PM, Ahmet Arslan <io...@yahoo.com> wrote:
>
> > Hi Mukund,
> >
> > I am not sure what you are after but may be you can use this : q={!lucene
> > df=city v=$qq}&qq=Adyar
> >
> >
> >
> >
> https://cwiki.apache.org/confluence/display/solr/Local+Parameters+in+Queries
> >
> > Ahmet
> >
> >
> >
> >
> > On Tuesday, January 7, 2014 3:39 PM, Mukundaraman valakumaresan <
> > mukund@8kmiles.com> wrote:
> > Hi
> >
> > The following query executes
> >
> >
> >
> http://localhost:8983/solr/collection1/select?wt=json&indent=true&q=locality:A
> > <
> >
> http://localhost:8983/solr/collection1/select?wt=json&indent=true&q=city:Chennai
> > >
> > dyar
> >
> > But I wanted something like the one below which is not working.
> >
> >
> >
> http://localhost:8983/solr/collection1/select?wt=json&indent=true&q=locality:$str&str
> > <
> >
> http://localhost:8983/solr/collection1/select?wt=json&indent=true&q=city:$str&str=Chennai
> > >
> > ="Adyar"
> >
> >
> >
> http://localhost:8983/solr/collection1/select?wt=json&indent=true&q=locality
> > :<
> >
> http://localhost:8983/solr/collection1/select?wt=json&indent=true&q=city:$str&str=Chennai
> > >
> > getAdjacentLocalities("Adyar")
> >
> > getAdjacentLocalities() is a custom function implemented.
> >
> > Any suggestions.
> >
> > Thanks & Regards
> > Mukund
> >
> >
>

Re: Passing variables as values in Query Filter

Posted by Mukundaraman valakumaresan <mu...@8kmiles.com>.
Hi Ahmet,

Thanks a lot

What I need is this .
q={!lucene df=city v=$qq}&qq=customfunc(x)

In this case,
qq=custfunc(x) --> where custfunc is a custom function that has to be
executed. Instead, how it acts now is, it takes it as a string to search
if qq  is a number, you will get a NumberFormatException

Thanks & Regards
Mukund



On Tue, Jan 7, 2014 at 7:45 PM, Ahmet Arslan <io...@yahoo.com> wrote:

> Hi Mukund,
>
> I am not sure what you are after but may be you can use this : q={!lucene
> df=city v=$qq}&qq=Adyar
>
>
>
> https://cwiki.apache.org/confluence/display/solr/Local+Parameters+in+Queries
>
> Ahmet
>
>
>
>
> On Tuesday, January 7, 2014 3:39 PM, Mukundaraman valakumaresan <
> mukund@8kmiles.com> wrote:
> Hi
>
> The following query executes
>
>
> http://localhost:8983/solr/collection1/select?wt=json&indent=true&q=locality:A
> <
> http://localhost:8983/solr/collection1/select?wt=json&indent=true&q=city:Chennai
> >
> dyar
>
> But I wanted something like the one below which is not working.
>
>
> http://localhost:8983/solr/collection1/select?wt=json&indent=true&q=locality:$str&str
> <
> http://localhost:8983/solr/collection1/select?wt=json&indent=true&q=city:$str&str=Chennai
> >
> ="Adyar"
>
>
> http://localhost:8983/solr/collection1/select?wt=json&indent=true&q=locality
> :<
> http://localhost:8983/solr/collection1/select?wt=json&indent=true&q=city:$str&str=Chennai
> >
> getAdjacentLocalities("Adyar")
>
> getAdjacentLocalities() is a custom function implemented.
>
> Any suggestions.
>
> Thanks & Regards
> Mukund
>
>

Re: Passing variables as values in Query Filter

Posted by Ahmet Arslan <io...@yahoo.com>.
Hi Mukund,

I am not sure what you are after but may be you can use this : q={!lucene df=city v=$qq}&qq=Adyar


https://cwiki.apache.org/confluence/display/solr/Local+Parameters+in+Queries

Ahmet




On Tuesday, January 7, 2014 3:39 PM, Mukundaraman valakumaresan <mu...@8kmiles.com> wrote:
Hi

The following query executes

http://localhost:8983/solr/collection1/select?wt=json&indent=true&q=locality:A<http://localhost:8983/solr/collection1/select?wt=json&indent=true&q=city:Chennai>
dyar

But I wanted something like the one below which is not working.

http://localhost:8983/solr/collection1/select?wt=json&indent=true&q=locality:$str&str<http://localhost:8983/solr/collection1/select?wt=json&indent=true&q=city:$str&str=Chennai>
="Adyar"

http://localhost:8983/solr/collection1/select?wt=json&indent=true&q=locality:<http://localhost:8983/solr/collection1/select?wt=json&indent=true&q=city:$str&str=Chennai>
getAdjacentLocalities("Adyar")

getAdjacentLocalities() is a custom function implemented.

Any suggestions.

Thanks & Regards
Mukund