Different Filters

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Different Filters

Owens, Martin
Hello all,

We have a requirement for being able to switch on and off certain filters for different searches.

The problem is that these filters are defined in the schema, per field; we only have one field with text so I was wondering if there was a way of setting the filters in the solrconfig.xml and create a different search a bit like the example but with different filters.

thoughts?

Best Regards, Martin Owens
Reply | Threaded
Open this post in threaded view
|

Re: Different Filters

Yonik Seeley-2
On Thu, Feb 21, 2008 at 1:20 PM, Owens, Martin
<[hidden email]> wrote:
>  We have a requirement for being able to switch on and off certain filters for different searches.

Can the client send in which filters should be turned on and off, but
leave the definition of the filters in solrconfig.xml?

If so, you can get this effect with the new query parser plugin
framework.  Part of that includes what I call "local parameters" (not
really documented yet), which includes parameter dereferencing.

So you could add something like this to your query
fq=<!val=$filter1>&fq=<!val=$filter3)
and have the various filters be a default defined in a handler in solrconfig.xml

-Yonik
Reply | Threaded
Open this post in threaded view
|

RE: Different Filters

Owens, Martin

> Can the client send in which filters should be turned on and off, but
> leave the definition of the filters in solrconfig.xml?

The client must set the property, how solr deals with that is how I want it to work.

> If so, you can get this effect with the new query parser plugin
> framework.  Part of that includes what I call "local parameters" (not
> really documented yet), which includes parameter dereferencing.

What version of solr does this first appear? we're using a nightly build from December which was heavily hacked to do database result returning and word offset highlighting (and some other fixes) so we'd like to avoid using anything newer.

> So you could add something like this to your query
> fq=<!val=$filter1>&fq=<!val=$filter3)
> and have the various filters be a default defined in a handler in solrconfig.xml

How does this work? I'm still confused from your explanation. Are the query options turning the filters on or off? what kind of hander would go into solrconfig.xml?

Best Regards, Martin Owens
Reply | Threaded
Open this post in threaded view
|

Re: Different Filters

Yonik Seeley-2
On Thu, Feb 21, 2008 at 1:49 PM, Owens, Martin
<[hidden email]> wrote:
>  > So you could add something like this to your query
>  > fq=<!val=$filter1>&fq=<!val=$filter3)
>  > and have the various filters be a default defined in a handler in solrconfig.xml
>
>  How does this work? I'm still confused from your explanation. Are the query options turning the filters on or off? what kind of hander would go into solrconfig.xml?

This feature was first committed 10/22/07

It's a simple indirection.
fq=myfield:myval
  is equivalent to
fq=<!val=$filter1>&filter1=myfield:myval

Now put filter1 as a default in your handler (same as any other
default), and the client can turn on and off filter1 without knowing
what exactly it is.

-Yonik
Reply | Threaded
Open this post in threaded view
|

RE: Different Filters

Owens, Martin


>> This feature was first committed 10/22/07

Great! should be there then.

> Now put filter1 as a default in your handler (same as any other
> default), and the client can turn on and off filter1 without knowing
> what exactly it is.

OK so I have to add a new search hander into solrconfig.xml with a set name,
I then use that in the query line to specify which field the search hander should use?

Are you able to do an example including the solrconfig or schema changes and show the field and how it works with the English Stemmer for instance.

Sorry for being a dunce today, I'm just not sure I'm totally understanding everything.

Best Regards, Martin Owens
Reply | Threaded
Open this post in threaded view
|

Re: Different Filters

Yonik Seeley-2
On Thu, Feb 21, 2008 at 2:17 PM, Owens, Martin
<[hidden email]> wrote:
>  > Now put filter1 as a default in your handler (same as any other
>  > default), and the client can turn on and off filter1 without knowing
>  > what exactly it is.
>
>  OK so I have to add a new search hander into solrconfig.xml with a set name,
>  I then use that in the query line to specify which field the search hander should use?

What field??? or what filter?
I'm not really sure I still understand what you are trying to accomplish.
Perhaps if you have some explicit examples of what types of things
clients would send in as query parameters to Solr, and what types of
lucene queries you actually want to be generated.

-Yonik
Reply | Threaded
Open this post in threaded view
|

RE: Different Filters

Owens, Martin

> What field??? or what filter?
> I'm not really sure I still understand what you are trying to accomplish.
> Perhaps if you have some explicit examples of what types of things
> clients would send in as query parameters to Solr, and what types of
> lucene queries you actually want to be generated.

Oh dear a complete break down,

OK so our perl based software uses http to set a request to solr, we want for our software to be able to control the query filters being used with each search by modifying attributes in the http query string such as I think you were suggesting. I need examples of how to impliment what you were talking about.

Best Regards, Martin Owens
Reply | Threaded
Open this post in threaded view
|

Re: Different Filters

Yonik Seeley-2
OK, talk of different fields threw me.

To enable a client to turn on/off a specific filter without knowing
what that filter is,
add the following parameter to the query string when you want to turn
the filter on:
fq=<!v=$filter1>

Then add a default for the filter1 param in lucene query syntax (like
+cat:electronics +inStock:true) to whatever handler you want to query
(refer to the examples in solrconfig.xml for how to do this).

-Yonik


On Thu, Feb 21, 2008 at 3:34 PM, Owens, Martin
<[hidden email]> wrote:

>
>  > What field??? or what filter?
>  > I'm not really sure I still understand what you are trying to accomplish.
>  > Perhaps if you have some explicit examples of what types of things
>  > clients would send in as query parameters to Solr, and what types of
>  > lucene queries you actually want to be generated.
>
>  Oh dear a complete break down,
>
>  OK so our perl based software uses http to set a request to solr, we want for our software to be able to control the query filters being used with each search by modifying attributes in the http query string such as I think you were suggesting. I need examples of how to impliment what you were talking about.
>
>  Best Regards, Martin Owens
>