Re: problem with formulating a negative query

2010-07-06 Thread Sascha Szott

Hi,

Chris Hostetter wrote:

AND, OR, and NOT are just syntactic-sugar for modifying
the MUST, MUST_NOT, and SHOULD.  The default op of OR only affects the
first clause of your query (R) because it doesn't have any modifiers --

Thanks for pointing that out!

-Sascha


the second clause has that NOT modifier so your query is effectivley...

topic:R -topic:[* TO *]

...which by definition can't match anything.

-Hoss



Re: problem with formulating a negative query

2010-07-02 Thread Chris Hostetter

: thanks for your explanations. But why are all docs being *removed* from the
: set of all docs that contain R in their topic field? This would correspond to
: a boolean AND and would stand in conflict with the clause q.op=OR. This seems
: a bit strange to me.

Erick's explanation might have been a tad missleading ... it's not an 
ordered operation, AND, OR, and NOT are just syntactic-sugar for modifying 
the MUST, MUST_NOT, and SHOULD.  The default op of OR only affects the 
first clause of your query (R) because it doesn't have any modifiers -- 
the second clause has that NOT modifier so your query is effectivley...

topic:R -topic:[* TO *]

...which by definition can't match anything.

-Hoss



Re: problem with formulating a negative query

2010-06-30 Thread Sascha Szott

Hi Erick,

thanks for your explanations. But why are all docs being *removed* from 
the set of all docs that contain R in their topic field? This would 
correspond to a boolean AND and would stand in conflict with the clause 
q.op=OR. This seems a bit strange to me.


Furthermore, Smiley  Pugh stated in their Solr 1.4 book on pg. 102 that 
adding the a subexpression containing the negative query (-[* TO *]) and 
the match-all-docs clause (*:*) is only a workaround. Why is this 
workaround necessary at all?


Best,
Sascha

Erick Erickson wrote:

This may help:
http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Boolean%20operators

But the clause you specified translates roughly as find all the
documents that contain R, then remove any of them that match
* TO *. * TO * contains all the documents with R, so everything
you just matched is removed from your results.

HTH
Erick

On Tue, Jun 29, 2010 at 12:40 PM, Sascha Szottsz...@zib.de  wrote:


Hi Ahmet,

it works, thanks a lot!

To be true I have no idea what's the problem with
defType=luceneq.op=ORdf=topicq=R NOT [* TO *]

-Sascha


Ahmet Arslan wrote:


I have a (multi-valued) field topic in my index which does

not need to exist in every document. Now, I'm struggling
with formulating a query that returns all documents that
either have no topic field at all *or* whose topic field
value is R.



Does this work?
defType=luceneq.op=ORq=topic:R (+*:* -topic:[* TO *])




problem with formulating a negative query

2010-06-29 Thread Sascha Szott

Hi folks,

I have a (multi-valued) field topic in my index which does not need to 
exist in every document. Now, I'm struggling with formulating a query 
that returns all documents that either have no topic field at all *or* 
whose topic field value is R.


Unfortunately, the query

/select?q={!lucene q.op=OR df=topic}(R NOT [* TO *])

does not return any docs even though there are documents in my index 
that fulfil the specified condition as you can deduce from the queries 
listed below:


/select?q=topic:R  returns  0 docs

/select?q=-topic:[* TO *]  returns  0 docs

Appending the query with debugQuery=true returns:
str name=rawquerystring{!lucene q.op=OR df=topic}(R NOT [* TO *])/str
str name=querystring{!lucene q.op=OR df=topic}(R NOT [* TO *])/str
str name=parsedquerytopic:R -topic:[* TO *]/str
str name=parsedquery_toStringtopic:R -topic:[* TO *]/str

Does anybody have a clue of what is wrong here?

Thanks in advance,
Sascha


Re: problem with formulating a negative query

2010-06-29 Thread Ahmet Arslan
 I have a (multi-valued) field topic in my index which does
 not need to exist in every document. Now, I'm struggling
 with formulating a query that returns all documents that
 either have no topic field at all *or* whose topic field
 value is R.

Does this work?
defType=luceneq.op=ORq=topic:R (+*:* -topic:[* TO *])


  


Re: problem with formulating a negative query

2010-06-29 Thread Erick Erickson
This may help:
http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Boolean%20operators

But the clause you specified translates roughly as find all the
documents that contain R, then remove any of them that match
* TO *. * TO * contains all the documents with R, so everything
you just matched is removed from your results.

HTH
Erick

On Tue, Jun 29, 2010 at 12:40 PM, Sascha Szott sz...@zib.de wrote:

 Hi Ahmet,

 it works, thanks a lot!

 To be true I have no idea what's the problem with
 defType=luceneq.op=ORdf=topicq=R NOT [* TO *]

 -Sascha


 Ahmet Arslan wrote:

 I have a (multi-valued) field topic in my index which does
 not need to exist in every document. Now, I'm struggling
 with formulating a query that returns all documents that
 either have no topic field at all *or* whose topic field
 value is R.


 Does this work?
 defType=luceneq.op=ORq=topic:R (+*:* -topic:[* TO *])