Re: How can I check if a more complex query condition matched?

2011-12-29 Thread Chris Hostetter

: I have a more complex query condition like this:
: 
: (city:15 AND country:60)^4 OR city:15^2 OR country:60^2
: 
: What I want to achive with this query is basically if a document has
: city = 15 AND country = 60 it is more important then another document
: which only has city = 15 OR country = 60

what you've got there will do that, but to a lesser degree so will a 
simple query for both clausees...

  q=(city:15 country:60)

will score documents higher if they match both clauses then if the only 
match one becaues of the coord factor -- you can check the debuqQuery 
score explanations to see the details.  If you want the descrepencies in 
scores to be more significant, you can go the route you have, or you can 
customize the similarity to stricter about the coord factor, but that will 
apply to all boolean queries.

: Furhtermore I want to show in my results view why a certain document
: matched, something like "matched city and country" or "matched city
: only" or "matched country only".

this is a bit trickier, but thanks to the new psuedo-fields feature it 
will work in 4.0 (and already works on the trunk)...

any function can be specified in the "fl" param and each document returned 
will include the value that document has for that function -- so 
regardless of how complex or simple your main query is, you could use the 
"query(...)" function in the fl to see what score it gets against some 
other arbitrary function...

Here's an example URL using the example data/configs...

http://localhost:8983/solr/select?q=hard+drive&fl=score,id,name,is_canon:query%28{!v=%27manu_id_s:canon%27}%29


-Hoss


Re: How can I check if a more complex query condition matched?

2011-12-28 Thread Erick Erickson
There's no easy/efficient way that I know of to do this. Perhaps a good
question is what value-add this is going to make for your app and is
there a better way to convey this information. For instance, would
highlighting convey "enough" information to your user?

You're right that you don't want to enable debug in production, it
can take quite a long time (see the timings when you DO enable
debug).

Could you consider some kind of one-off when a user really, really
needs this info where you *do* add debugQuery=on but restrict
the query to a single document they're interested in?

Best
Erick

On Wed, Dec 28, 2011 at 5:30 AM, Max  wrote:
> Thanks for your reply, I thought about using the debug mode, too, but
> the information is not easy to parse and doesnt contain everything I
> want. Furthermore I dont want to enable debug mode in production.
>
> Is there anything else I could try?
>
> On Tue, Dec 27, 2011 at 12:48 PM, Ahmet Arslan  wrote:
>>> I have a more complex query condition
>>> like this:
>>>
>>> (city:15 AND country:60)^4 OR city:15^2 OR country:60^2
>>>
>>> What I want to achive with this query is basically if a
>>> document has
>>> city = 15 AND country = 60 it is more important then
>>> another document
>>> which only has city = 15 OR country = 60
>>>
>>> Furhtermore I want to show in my results view why a certain
>>> document
>>> matched, something like "matched city and country" or
>>> "matched city
>>> only" or "matched country only".
>>>
>>> This is a bit of an simplified example, but the question
>>> remains: how
>>> can solr tell me which of the conditions in the query
>>> matched? If I
>>> match against a simple field only, I can get away with
>>> highlight
>>> fields, but conditions spanning multiple fields seem much
>>> more tricky.
>>
>> Looks like you can extract these info from output of &debugQuery=on.
>> http://wiki.apache.org/solr/CommonQueryParameters#debugQuery
>>


Re: How can I check if a more complex query condition matched?

2011-12-28 Thread Max
Thanks for your reply, I thought about using the debug mode, too, but
the information is not easy to parse and doesnt contain everything I
want. Furthermore I dont want to enable debug mode in production.

Is there anything else I could try?

On Tue, Dec 27, 2011 at 12:48 PM, Ahmet Arslan  wrote:
>> I have a more complex query condition
>> like this:
>>
>> (city:15 AND country:60)^4 OR city:15^2 OR country:60^2
>>
>> What I want to achive with this query is basically if a
>> document has
>> city = 15 AND country = 60 it is more important then
>> another document
>> which only has city = 15 OR country = 60
>>
>> Furhtermore I want to show in my results view why a certain
>> document
>> matched, something like "matched city and country" or
>> "matched city
>> only" or "matched country only".
>>
>> This is a bit of an simplified example, but the question
>> remains: how
>> can solr tell me which of the conditions in the query
>> matched? If I
>> match against a simple field only, I can get away with
>> highlight
>> fields, but conditions spanning multiple fields seem much
>> more tricky.
>
> Looks like you can extract these info from output of &debugQuery=on.
> http://wiki.apache.org/solr/CommonQueryParameters#debugQuery
>


Re: How can I check if a more complex query condition matched?

2011-12-27 Thread Ahmet Arslan
> I have a more complex query condition
> like this:
> 
> (city:15 AND country:60)^4 OR city:15^2 OR country:60^2
> 
> What I want to achive with this query is basically if a
> document has
> city = 15 AND country = 60 it is more important then
> another document
> which only has city = 15 OR country = 60
> 
> Furhtermore I want to show in my results view why a certain
> document
> matched, something like "matched city and country" or
> "matched city
> only" or "matched country only".
> 
> This is a bit of an simplified example, but the question
> remains: how
> can solr tell me which of the conditions in the query
> matched? If I
> match against a simple field only, I can get away with
> highlight
> fields, but conditions spanning multiple fields seem much
> more tricky.

Looks like you can extract these info from output of &debugQuery=on.
http://wiki.apache.org/solr/CommonQueryParameters#debugQuery