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 climbingrose <cl...@gmail.com> on 2008/01/02 08:54:59 UTC

Filter Query and query score

Hi all,

Here is my situation:

I'm implementing some geographical search functions that allows user to
search for documents close to a location. Because not all documents have
proper location information that can be converted to (latitude, longitude)
coordinate, I also have to use normal full text search to filter out
documents. For example, if users search for "Java" in "Parramatta, NSW" and
the following documents are in the index:

Doc1: [Title=Java; Location=Parramatta, NSW; latitude=x1; longitude=x2]
Doc2: [Title=Java; Location=North Ryde, NSW; latitude=x3; longitude=x4]
Doc3: [Title=Java; Location=Parramatta]

My filter query looks like this:

fq= (+latitude[lat1 TO lat2] +longitude[lng1 TO lng2]) location:Parramatta
location:NSW

Now assuming that my query matches those three documents, I need to make
sure that documents with "Parramatta" in their locations have some kind of
boost to the final score. For example, I'd like to have Doc3 listed before
Doc2 because it has "Parramatta" in location field.

Is this possible? Thanks in advance!

-- 
Regards,

Cuong Hoang

Re: Filter Query and query score

Posted by tedonk03 <te...@gmail.com>.
Hi,

it seems it works now. I put some mistakes on the calculation. But is there
any limit to the query size in Solr? Thanx again



I tried the code but it seems it's not working properly. I tried to check it
by inserting
bq=location:Parramatta^1.4 location:NS^1.4 location:North Ryde^1.4

If I use it like that, I should get the same result order with the result if
I do it without bq, right?
But it seems that the result shows Paramatta results on top, followed by NS,
and the North RYde.
I tried to change the boosting number to 1.0 so the result will be the same
like the result without bq, but still nothing change, it is still in the
grouping order. I am not sure if the bq works properly.

Actually I used this in ruby to send the request to Solr, so the code looks
like this
:q => query,
:wt => 'ruby', 
:bq => 'location:Parramatta^1.4 location:NS^1.4 location:North Ryde^1.4'

Thanx for the help

- Ted


-- 
View this message in context: http://www.nabble.com/Filter-Query-and-query-score-tp14574793p15560572.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Filter Query and query score

Posted by tedonk03 <te...@gmail.com>.
I tried the code but it seems it's not working properly. I tried to check it
by inserting
bq=location:Parramatta^1.4 location:NS^1.4 location:North Ryde^1.4

If I use it like that, I should get the same result order with the result if
I do it without bq, right?
But it seems that the result shows Paramatta results on top, followed by NS,
and the North RYde.
I tried to change the boosting number to 1.0 so the result will be the same
like the result without bq, but still nothing change, it is still in the
grouping order. I am not sure if the bq works properly.

Actually I used this in ruby to send the request to Solr, so the code looks
like this
:q => query,
:wt => 'ruby', 
:bq => 'location:Parramatta^1.4 location:NS^1.4 location:North Ryde^1.4'

Thanx for the help

- Ted



Mike Klaas wrote:
> 
> On 14-Feb-08, at 6:51 AM, tedonk03 wrote:
> 
>>
>> Hi,
>>
>> I also have the same problem. My case is similar like this, but the  
>> user can
>> select their preferences. I´ll use climbingrose´s example but add it a
>> little bit.
>>
>> Doc1: [Title=Java; Location=Parramatta, NSW; latitude=x1;  
>> longitude=x2]
>> Doc2: [Title=Java; Location=North Ryde, NSW; latitude=x3;  
>> longitude=x4]
>> Doc3: [Title=Java; Location=Parramatta]
>> Doc4: [Title=Java; Location=NS, NSW; latitude=x1; longitude=x2]
>> Doc5: [Title=Java; Location=NS, NSW; latitude=x3; longitude=x4]
>> Doc6: [Title=Java; Location=Parramatta]
>>
>> For example the user query is Java and their preferences are  
>> Paramatta and
>> NS, so I would like to boost the documents with location Paramatta  
>> or NS.
>> But still I want to show the result from another location. How do I  
>> use it
>> in bq? Can I use it like this:
>>
>>  bq=location:Parramatta^1.4 || location:NS^1.4
> 
> "or" is implied:
> 
> bq=location:Parramatta^1.4 location:NS^1.4
> 
> alternatively, you can use multiple bq's
> 
> bq=location:Parramatta^1.4
> bq=location:NS^1.4
> 
> see http://wiki.apache.org/solr/SolrQuerySyntax
> 
> -Mike
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Filter-Query-and-query-score-tp14574793p15496947.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Filter Query and query score

Posted by Mike Klaas <mi...@gmail.com>.
On 14-Feb-08, at 6:51 AM, tedonk03 wrote:

>
> Hi,
>
> I also have the same problem. My case is similar like this, but the  
> user can
> select their preferences. I´ll use climbingrose´s example but add it a
> little bit.
>
> Doc1: [Title=Java; Location=Parramatta, NSW; latitude=x1;  
> longitude=x2]
> Doc2: [Title=Java; Location=North Ryde, NSW; latitude=x3;  
> longitude=x4]
> Doc3: [Title=Java; Location=Parramatta]
> Doc4: [Title=Java; Location=NS, NSW; latitude=x1; longitude=x2]
> Doc5: [Title=Java; Location=NS, NSW; latitude=x3; longitude=x4]
> Doc6: [Title=Java; Location=Parramatta]
>
> For example the user query is Java and their preferences are  
> Paramatta and
> NS, so I would like to boost the documents with location Paramatta  
> or NS.
> But still I want to show the result from another location. How do I  
> use it
> in bq? Can I use it like this:
>
>  bq=location:Parramatta^1.4 || location:NS^1.4

"or" is implied:

bq=location:Parramatta^1.4 location:NS^1.4

alternatively, you can use multiple bq's

bq=location:Parramatta^1.4
bq=location:NS^1.4

see http://wiki.apache.org/solr/SolrQuerySyntax

-Mike


Re: Filter Query and query score

Posted by tedonk03 <te...@gmail.com>.
Hi, 

I also have the same problem. My case is similar like this, but the user can
select their preferences. I´ll use climbingrose´s example but add it a
little bit.

Doc1: [Title=Java; Location=Parramatta, NSW; latitude=x1; longitude=x2]
Doc2: [Title=Java; Location=North Ryde, NSW; latitude=x3; longitude=x4]
Doc3: [Title=Java; Location=Parramatta]
Doc4: [Title=Java; Location=NS, NSW; latitude=x1; longitude=x2]
Doc5: [Title=Java; Location=NS, NSW; latitude=x3; longitude=x4]
Doc6: [Title=Java; Location=Parramatta]

For example the user query is Java and their preferences are Paramatta and
NS, so I would like to boost the documents with location Paramatta or NS.
But still I want to show the result from another location. How do I use it
in bq? Can I use it like this:

 bq=location:Parramatta^1.4 || location:NS^1.4

is that correct? I tried but it seems it didn´t work.

So the final result I want that NS and Paramatta get a little boost to the
top and NOrth Ryde goes to the bottom. Is that possible? Thanx

- Ted -


Mike Klaas wrote:
> 
> On 1-Jan-08, at 11:54 PM, climbingrose wrote:
>>
>> Doc1: [Title=Java; Location=Parramatta, NSW; latitude=x1;  
>> longitude=x2]
>> Doc2: [Title=Java; Location=North Ryde, NSW; latitude=x3;  
>> longitude=x4]
>> Doc3: [Title=Java; Location=Parramatta]
>>
>> My filter query looks like this:
>>
>> fq= (+latitude[lat1 TO lat2] +longitude[lng1 TO lng2])  
>> location:Parramatta
>> location:NSW
>>
>> Now assuming that my query matches those three documents, I need to  
>> make
>> sure that documents with "Parramatta" in their locations have some  
>> kind of
>> boost to the final score. For example, I'd like to have Doc3 listed  
>> before
>> Doc2 because it has "Parramatta" in location field.
>>
>> Is this possible? Thanks in advance!
> 
> Sure, just also add a boost parameter:
> 
> fq= (+latitude[lat1 TO lat2] +longitude[lng1 TO lng2])  
> location:Parramatta location:NSW
> bq=location:Parramatta^1.4
> 
> -Mike
> 
> 

-- 
View this message in context: http://www.nabble.com/Filter-Query-and-query-score-tp14574793p15480679.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Filter Query and query score

Posted by Mike Klaas <mi...@gmail.com>.
On 1-Jan-08, at 11:54 PM, climbingrose wrote:
>
> Doc1: [Title=Java; Location=Parramatta, NSW; latitude=x1;  
> longitude=x2]
> Doc2: [Title=Java; Location=North Ryde, NSW; latitude=x3;  
> longitude=x4]
> Doc3: [Title=Java; Location=Parramatta]
>
> My filter query looks like this:
>
> fq= (+latitude[lat1 TO lat2] +longitude[lng1 TO lng2])  
> location:Parramatta
> location:NSW
>
> Now assuming that my query matches those three documents, I need to  
> make
> sure that documents with "Parramatta" in their locations have some  
> kind of
> boost to the final score. For example, I'd like to have Doc3 listed  
> before
> Doc2 because it has "Parramatta" in location field.
>
> Is this possible? Thanks in advance!

Sure, just also add a boost parameter:

fq= (+latitude[lat1 TO lat2] +longitude[lng1 TO lng2])  
location:Parramatta location:NSW
bq=location:Parramatta^1.4

-Mike