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 Mark Robinson <ma...@gmail.com> on 2016/10/02 15:29:33 UTC
Reading a prameter set in browser in request handler
Hi,
I pass a parameter *&country=USA* from the browser as part of my query.
(I have fields *weather_USA*, *weather_UK* etc... in my document).
How do I retrieve the parameter "country" in my requesthandler.
I tried in my requesthandler:-
<lst name="defaults">
<str name="country">storeId</str>
<str name="weather">weather_${country}</str>
...but it is not working. Even tried:-
<str name="weather">weather_$country</str>
I am trying to set my weather field based on the *country *passed.
Any suggestionsis is highly appreciated.
Thanks!
Mark
Re: Reading a prameter set in browser in request handler
Posted by Mark Robinson <ma...@gmail.com>.
Hi,
While copy pasting correcting a typo.
I pass a parameter *&country=USA* from the browser as part of my query.
(I have fields *weather_USA*, *weather_UK* etc... in my document).
How do I retrieve the parameter "country" in my requesthandler.
I tried in my requesthandler:-
<lst name="defaults">
<str name="country">country</str>
<str name="weather">weather_${country}</str>
...but it is not working. Even tried:-
<str name="weather">weather_$country</str>
I am trying to set my weather field based on the *country *passed.
Any suggestionsis is highly appreciated.
Thanks!
On Sun, Oct 2, 2016 at 11:29 AM, Mark Robinson <ma...@gmail.com>
wrote:
> Hi,
>
> I pass a parameter *&country=USA* from the browser as part of my query.
> (I have fields *weather_USA*, *weather_UK* etc... in my document).
> How do I retrieve the parameter "country" in my requesthandler.
>
> I tried in my requesthandler:-
>
> <lst name="defaults">
> <str name="country">storeId</str>
> <str name="weather">weather_${country}</str>
>
> ...but it is not working. Even tried:-
> <str name="weather">weather_$country</str>
>
> I am trying to set my weather field based on the *country *passed.
>
> Any suggestionsis is highly appreciated.
>
> Thanks!
> Mark
>
Re: Reading a prameter set in browser in request handler
Posted by Walter Underwood <wu...@wunderwood.org>.
We have a different problem, then.
Accessing Solr directly from the web is a very, very bad idea. Solr is not designed for hostile web access. I’m glad to share with you a simple command that will delete all the documents in your index. Works great.
So step #1 is to put some kind of server between the browser and Solr. That server can make substitutions. Or you can have a request handler for each locale.
wunder
Walter Underwood
wunder@wunderwood.org
http://observer.wunderwood.org/ (my blog)
> On Oct 2, 2016, at 9:19 AM, Mark Robinson <ma...@gmail.com> wrote:
>
> Thanks Alex for the reply.
>
> Yes. in this context I want to determine the weather of the country passed
> from browser which will go into another function query.
>
> If I do the above directly from the browser it works great. I am trying to
> move this to the requesthandler so that I need to pass only the country
> name which is what varies.
> If all parameters in the browser itself:-
> &country=USA&climate=if (weatherDetermine, weather_${country},
> defaultField).
>
> Basically I am trying to configure most of my params in request handler so
> that I need to pass only one param that actually varies, reducing my query
> url length.
>
> So baseically was trying to find out *how I can access a parameter passed
> from the browser in a request handler to determine on a field dynamically
> using the info passed from browser.*
>
> Thanks!
> Mark
>
>
> On Sun, Oct 2, 2016 at 11:46 AM, Alexandre Rafalovitch <ar...@gmail.com>
> wrote:
>
>> The variable substitution in the solrconfig.xml happens when that file
>> is loaded, right at the start of core initialization. Your request
>> variable comes much later. I don't think you can expand it this way.
>>
>> Could you explain a bit more what you are trying to achieve in
>> business terms. E.g. 'weather' term needs to feed into something else
>> in query I am guessing.
>>
>> Regards,
>> Alex.
>> ----
>> Newsletter and resources for Solr beginners and intermediates:
>> http://www.solr-start.com/
>>
>>
>> On 2 October 2016 at 22:29, Mark Robinson <ma...@gmail.com> wrote:
>>> Hi,
>>>
>>> I pass a parameter *&country=USA* from the browser as part of my query.
>>> (I have fields *weather_USA*, *weather_UK* etc... in my document).
>>> How do I retrieve the parameter "country" in my requesthandler.
>>>
>>> I tried in my requesthandler:-
>>>
>>> <lst name="defaults">
>>> <str name="country">storeId</str>
>>> <str name="weather">weather_${country}</str>
>>>
>>> ...but it is not working. Even tried:-
>>> <str name="weather">weather_$country</str>
>>>
>>> I am trying to set my weather field based on the *country
>> *passed.
>>>
>>> Any suggestionsis is highly appreciated.
>>>
>>> Thanks!
>>> Mark
>>
Re: Reading a prameter set in browser in request handler
Posted by Mark Robinson <ma...@gmail.com>.
Thanks much Alex!
Your pointer was helpful.
Thanks!
Anil.
On Sun, Oct 2, 2016 at 12:28 PM, Alexandre Rafalovitch <ar...@gmail.com>
wrote:
> You've got Parameter Substitution:
> https://cwiki.apache.org/confluence/display/solr/Parameter+Substitution
>
> I think this should do the trick. Perhaps combined with switch query
> parser as https://cwiki.apache.org/confluence/display/solr/Other+
> Parsers#OtherParsers-SwitchQueryParser
> (like in an example here:
> https://gist.github.com/arafalov/5e04884e5aefaf46678c )
>
> Regards,
> Alex.
> ----
> Newsletter and resources for Solr beginners and intermediates:
> http://www.solr-start.com/
>
>
> On 2 October 2016 at 23:19, Mark Robinson <ma...@gmail.com> wrote:
> > Thanks Alex for the reply.
> >
> > Yes. in this context I want to determine the weather of the country
> passed
> > from browser which will go into another function query.
> >
> > If I do the above directly from the browser it works great. I am trying
> to
> > move this to the requesthandler so that I need to pass only the country
> > name which is what varies.
> > If all parameters in the browser itself:-
> > &country=USA&climate=if (weatherDetermine, weather_${country},
> > defaultField).
> >
> > Basically I am trying to configure most of my params in request handler
> so
> > that I need to pass only one param that actually varies, reducing my
> query
> > url length.
> >
> > So baseically was trying to find out *how I can access a parameter passed
> > from the browser in a request handler to determine on a field dynamically
> > using the info passed from browser.*
> >
> > Thanks!
> > Mark
> >
> >
> > On Sun, Oct 2, 2016 at 11:46 AM, Alexandre Rafalovitch <
> arafalov@gmail.com>
> > wrote:
> >
> >> The variable substitution in the solrconfig.xml happens when that file
> >> is loaded, right at the start of core initialization. Your request
> >> variable comes much later. I don't think you can expand it this way.
> >>
> >> Could you explain a bit more what you are trying to achieve in
> >> business terms. E.g. 'weather' term needs to feed into something else
> >> in query I am guessing.
> >>
> >> Regards,
> >> Alex.
> >> ----
> >> Newsletter and resources for Solr beginners and intermediates:
> >> http://www.solr-start.com/
> >>
> >>
> >> On 2 October 2016 at 22:29, Mark Robinson <ma...@gmail.com>
> wrote:
> >> > Hi,
> >> >
> >> > I pass a parameter *&country=USA* from the browser as part of my
> query.
> >> > (I have fields *weather_USA*, *weather_UK* etc... in my document).
> >> > How do I retrieve the parameter "country" in my requesthandler.
> >> >
> >> > I tried in my requesthandler:-
> >> >
> >> > <lst name="defaults">
> >> > <str name="country">storeId</str>
> >> > <str name="weather">weather_${country}</str>
> >> >
> >> > ...but it is not working. Even tried:-
> >> > <str name="weather">weather_$country</str>
> >> >
> >> > I am trying to set my weather field based on the *country
> >> *passed.
> >> >
> >> > Any suggestionsis is highly appreciated.
> >> >
> >> > Thanks!
> >> > Mark
> >>
>
Re: Reading a prameter set in browser in request handler
Posted by Alexandre Rafalovitch <ar...@gmail.com>.
You've got Parameter Substitution:
https://cwiki.apache.org/confluence/display/solr/Parameter+Substitution
I think this should do the trick. Perhaps combined with switch query
parser as https://cwiki.apache.org/confluence/display/solr/Other+Parsers#OtherParsers-SwitchQueryParser
(like in an example here:
https://gist.github.com/arafalov/5e04884e5aefaf46678c )
Regards,
Alex.
----
Newsletter and resources for Solr beginners and intermediates:
http://www.solr-start.com/
On 2 October 2016 at 23:19, Mark Robinson <ma...@gmail.com> wrote:
> Thanks Alex for the reply.
>
> Yes. in this context I want to determine the weather of the country passed
> from browser which will go into another function query.
>
> If I do the above directly from the browser it works great. I am trying to
> move this to the requesthandler so that I need to pass only the country
> name which is what varies.
> If all parameters in the browser itself:-
> &country=USA&climate=if (weatherDetermine, weather_${country},
> defaultField).
>
> Basically I am trying to configure most of my params in request handler so
> that I need to pass only one param that actually varies, reducing my query
> url length.
>
> So baseically was trying to find out *how I can access a parameter passed
> from the browser in a request handler to determine on a field dynamically
> using the info passed from browser.*
>
> Thanks!
> Mark
>
>
> On Sun, Oct 2, 2016 at 11:46 AM, Alexandre Rafalovitch <ar...@gmail.com>
> wrote:
>
>> The variable substitution in the solrconfig.xml happens when that file
>> is loaded, right at the start of core initialization. Your request
>> variable comes much later. I don't think you can expand it this way.
>>
>> Could you explain a bit more what you are trying to achieve in
>> business terms. E.g. 'weather' term needs to feed into something else
>> in query I am guessing.
>>
>> Regards,
>> Alex.
>> ----
>> Newsletter and resources for Solr beginners and intermediates:
>> http://www.solr-start.com/
>>
>>
>> On 2 October 2016 at 22:29, Mark Robinson <ma...@gmail.com> wrote:
>> > Hi,
>> >
>> > I pass a parameter *&country=USA* from the browser as part of my query.
>> > (I have fields *weather_USA*, *weather_UK* etc... in my document).
>> > How do I retrieve the parameter "country" in my requesthandler.
>> >
>> > I tried in my requesthandler:-
>> >
>> > <lst name="defaults">
>> > <str name="country">storeId</str>
>> > <str name="weather">weather_${country}</str>
>> >
>> > ...but it is not working. Even tried:-
>> > <str name="weather">weather_$country</str>
>> >
>> > I am trying to set my weather field based on the *country
>> *passed.
>> >
>> > Any suggestionsis is highly appreciated.
>> >
>> > Thanks!
>> > Mark
>>
Re: Reading a prameter set in browser in request handler
Posted by Mark Robinson <ma...@gmail.com>.
Thanks Alex for the reply.
Yes. in this context I want to determine the weather of the country passed
from browser which will go into another function query.
If I do the above directly from the browser it works great. I am trying to
move this to the requesthandler so that I need to pass only the country
name which is what varies.
If all parameters in the browser itself:-
&country=USA&climate=if (weatherDetermine, weather_${country},
defaultField).
Basically I am trying to configure most of my params in request handler so
that I need to pass only one param that actually varies, reducing my query
url length.
So baseically was trying to find out *how I can access a parameter passed
from the browser in a request handler to determine on a field dynamically
using the info passed from browser.*
Thanks!
Mark
On Sun, Oct 2, 2016 at 11:46 AM, Alexandre Rafalovitch <ar...@gmail.com>
wrote:
> The variable substitution in the solrconfig.xml happens when that file
> is loaded, right at the start of core initialization. Your request
> variable comes much later. I don't think you can expand it this way.
>
> Could you explain a bit more what you are trying to achieve in
> business terms. E.g. 'weather' term needs to feed into something else
> in query I am guessing.
>
> Regards,
> Alex.
> ----
> Newsletter and resources for Solr beginners and intermediates:
> http://www.solr-start.com/
>
>
> On 2 October 2016 at 22:29, Mark Robinson <ma...@gmail.com> wrote:
> > Hi,
> >
> > I pass a parameter *&country=USA* from the browser as part of my query.
> > (I have fields *weather_USA*, *weather_UK* etc... in my document).
> > How do I retrieve the parameter "country" in my requesthandler.
> >
> > I tried in my requesthandler:-
> >
> > <lst name="defaults">
> > <str name="country">storeId</str>
> > <str name="weather">weather_${country}</str>
> >
> > ...but it is not working. Even tried:-
> > <str name="weather">weather_$country</str>
> >
> > I am trying to set my weather field based on the *country
> *passed.
> >
> > Any suggestionsis is highly appreciated.
> >
> > Thanks!
> > Mark
>
Re: Reading a prameter set in browser in request handler
Posted by Alexandre Rafalovitch <ar...@gmail.com>.
The variable substitution in the solrconfig.xml happens when that file
is loaded, right at the start of core initialization. Your request
variable comes much later. I don't think you can expand it this way.
Could you explain a bit more what you are trying to achieve in
business terms. E.g. 'weather' term needs to feed into something else
in query I am guessing.
Regards,
Alex.
----
Newsletter and resources for Solr beginners and intermediates:
http://www.solr-start.com/
On 2 October 2016 at 22:29, Mark Robinson <ma...@gmail.com> wrote:
> Hi,
>
> I pass a parameter *&country=USA* from the browser as part of my query.
> (I have fields *weather_USA*, *weather_UK* etc... in my document).
> How do I retrieve the parameter "country" in my requesthandler.
>
> I tried in my requesthandler:-
>
> <lst name="defaults">
> <str name="country">storeId</str>
> <str name="weather">weather_${country}</str>
>
> ...but it is not working. Even tried:-
> <str name="weather">weather_$country</str>
>
> I am trying to set my weather field based on the *country *passed.
>
> Any suggestionsis is highly appreciated.
>
> Thanks!
> Mark