Filter question...

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

Filter question...

escher2k
I have a bunch of fields that I am trying to filter on.

When I try to filter the data across the multiple fields, the result seems to even retrieve fields where the data is not present.

For instance if the filter query contains this -
primary_state:New Delhi OR primary_country:New Delhi OR primary_city:New Delhi OR secondary_state:New Delhi OR secondary_country:New Delhi

The result retrieved even contains records that have "Rochester, New York".

Is there a way to only retrieve those records that contain both the words "New" and "Delhi".

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Filter question...

jenix

>Is there a way to only retrieve those records that contain both the
>words "New" and "Delhi".

I'm just starting with this, put I found you need to do;
primary_state:"New Delhi"

I never used the OR yet!


Reply | Threaded
Open this post in threaded view
|

Re: Filter question...

escher2k
Thanks Jennifer. But the issue with the quotes would be that it would match the string exactly and
not find it, if there were other words in between (e.g. New Capital Delhi).

Jennifer Seaman wrote
>Is there a way to only retrieve those records that contain both the
>words "New" and "Delhi".

I'm just starting with this, put I found you need to do;
primary_state:"New Delhi"

I never used the OR yet!

Reply | Threaded
Open this post in threaded view
|

Re: Filter question...

Mike Klaas
On 4/19/07, escher2k <[hidden email]> wrote:
>
> Thanks Jennifer. But the issue with the quotes would be that it would match
> the string exactly and
> not find it, if there were other words in between (e.g. New Capital Delhi).

If you want to restrict a section of a query to a field, use brackets:

city:(.....)

thus:

city:(New Delhi) --> city contains 'new' or 'delhi', highest score to
those containing both
city:(+New +Delhi) --> city contains 'new' AND city contains 'delhi'
city:"New Delhi"~1000 --> city contain 'new' with 1000 words of
'delhi', highest score to matches having the words nearby

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

Re: Filter question...

Chris Hostetter-3
In reply to this post by escher2k

: not find it, if there were other words in between (e.g. New Capital Delhi).

then you should use field:"New Delhi"~3 or (+field:New +field:Delhi) what
you have now is going to match any docs that have "New" in any of the
fields you care about or Delhi in whatever you default search field is.

incidently, your use case seems like it *desperately* cries out for you to
use the dismax handler...

qt=dismax&q=New+Delhi&qf=primary_state^2+primary_country^2+primary_city^3+secondary_state+secondary_country&pf=primary_state^2+primary_country^2+primary_city^3+secondary_state+secondary_country&ps=5&mm=100

http://wiki.apache.org/solr/DisMaxRequestHandler
http://lucene.apache.org/solr/api/org/apache/solr/request/DisMaxRequestHandler.html





-Hoss

Reply | Threaded
Open this post in threaded view
|

Re: Filter question...

escher2k
Thanks Chris. We are using dismax already :)

Chris Hostetter wrote
: not find it, if there were other words in between (e.g. New Capital Delhi).

then you should use field:"New Delhi"~3 or (+field:New +field:Delhi) what
you have now is going to match any docs that have "New" in any of the
fields you care about or Delhi in whatever you default search field is.

incidently, your use case seems like it *desperately* cries out for you to
use the dismax handler...

qt=dismax&q=New+Delhi&qf=primary_state^2+primary_country^2+primary_city^3+secondary_state+secondary_country&pf=primary_state^2+primary_country^2+primary_city^3+secondary_state+secondary_country&ps=5&mm=100

http://wiki.apache.org/solr/DisMaxRequestHandler
http://lucene.apache.org/solr/api/org/apache/solr/request/DisMaxRequestHandler.html





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

Re: Filter question...

escher2k
In reply to this post by Mike Klaas
Thanks Mike. I just tested it on one field and looks like it works fine.

Mike Klaas wrote
On 4/19/07, escher2k <escher2k@yahoo.com> wrote:
>
> Thanks Jennifer. But the issue with the quotes would be that it would match
> the string exactly and
> not find it, if there were other words in between (e.g. New Capital Delhi).

If you want to restrict a section of a query to a field, use brackets:

city:(.....)

thus:

city:(New Delhi) --> city contains 'new' or 'delhi', highest score to
those containing both
city:(+New +Delhi) --> city contains 'new' AND city contains 'delhi'
city:"New Delhi"~1000 --> city contain 'new' with 1000 words of
'delhi', highest score to matches having the words nearby

-Mike