Re: Problem with query negation

2012-05-18 Thread Ahmet Arslan
 I am trying the following query and get only zero results (I
 am supposed to
 get 10 results according to my dataset)
 
 *http://mymachine:8983/solr/select/?q=-(HOSTID:302)*
 
 I also tried the below query and got zero results yet
 again.
 
 *http://mymachine:8983/solr/select/?q=NOT(HOSTID:302)*
 
 However, I get 10 results(expected) when I put the query
 this way,
 
 *http://mymachine:8983/solr/select/?q=-(HOSTID:302)AND(*:*)*
 
 Why is this strange thing happening? Is it a bug in solr or
 am I missing
 something?

Why don't you just use /solr/select/?q=-HOSTID:302


Re: Problem with query negation

2012-05-18 Thread Ramprakash Ramamoorthy
On Fri, May 18, 2012 at 5:03 PM, Ahmet Arslan iori...@yahoo.com wrote:

  I am trying the following query and get only zero results (I
  am supposed to
  get 10 results according to my dataset)
 
  *http://mymachine:8983/solr/select/?q=-(HOSTID:302)*
 
  I also tried the below query and got zero results yet
  again.
 
  *http://mymachine:8983/solr/select/?q=NOT(HOSTID:302)*
 
  However, I get 10 results(expected) when I put the query
  this way,
 
  *http://mymachine:8983/solr/select/?q=-(HOSTID:302)AND(*:*)*
 
  Why is this strange thing happening? Is it a bug in solr or
  am I missing
  something?

 Why don't you just use /solr/select/?q=-HOSTID:302


Tried the same right at start, but never worked :(


-- 
With Thanks and Regards,
Ramprakash Ramamoorthy,
Project Trainee,
Zoho Corporation.
+91 9626975420


Re: Problem with query negation

2012-05-18 Thread Ahmet Arslan
  Why don't you just use /solr/select/?q=-HOSTID:302
 
 
 Tried the same right at start, but never worked :(

q=-HOSTID:302 and q=+*:* -HOSTID:302 should return same result set. 
Which solr version and query parser are you using?


Re: Problem with query negation

2012-05-18 Thread Ramprakash Ramamoorthy
On Fri, May 18, 2012 at 6:03 PM, Ahmet Arslan iori...@yahoo.com wrote:

   Why don't you just use /solr/select/?q=-HOSTID:302
  
 
  Tried the same right at start, but never worked :(

 q=-HOSTID:302 and q=+*:* -HOSTID:302 should return same result set.
 Which solr version and query parser are you using?


I am using the standard LuceneQParserPlugin and I have a custom request
handler. I use solr 3.5

-- 
With Thanks and Regards,
Ramprakash Ramamoorthy,
Engineer Trainee,
Zoho Corporation.
+91 9626975420


Re: Problem with query negation

2012-05-18 Thread Ahmet Arslan
 I am using the standard LuceneQParserPlugin and I have a
 custom request
 handler. I use solr 3.5

I would test the same query with standard request handler. May be something is 
your custom request handler? 

debugQuery=on would help too.


Re: Problem with query negation

2012-05-18 Thread Ramprakash Ramamoorthy
On Fri, May 18, 2012 at 6:20 PM, Ahmet Arslan iori...@yahoo.com wrote:

  I am using the standard LuceneQParserPlugin and I have a
  custom request
  handler. I use solr 3.5

 I would test the same query with standard request handler. May be
 something is your custom request handler?

 I don't think request handler should be a problem. I have just used the *q
*parameter as follows.

String q = params.get(CommonParams.Q);
IndexSchema schema = req.getSchema();
Query query = new QueryParsing().parseQuery(q, schema);

Hope there shouldn't be a problem with the above!


 debugQuery=on would help too.




-- 
With Thanks and Regards,
Ramprakash Ramamoorthy,
Project Trainee,
Zoho Corporation.
+91 9626975420


Re: Problem with query negation

2012-05-18 Thread Ahmet Arslan
  I don't think request handler should be a problem. I
 have just used the *q
 *parameter as follows.
 
 String q = params.get(CommonParams.Q);
 IndexSchema schema = req.getSchema();
 Query query = new QueryParsing().parseQuery(q, schema);
 
 Hope there shouldn't be a problem with the above!

Solr converts top level negative query (-field:something) into q=+*:* 
-field:something

It seems that you are missing that part.

org.apache.solr.search.QueryUtils

/** Fixes a negative query by adding a MatchAllDocs query clause.
   * The query passed in *must* be a negative query.
   */
  public static Query fixNegativeQuery(Query q) {
BooleanQuery newBq = (BooleanQuery)q.clone();
newBq.add(new MatchAllDocsQuery(), BooleanClause.Occur.MUST);
return newBq;
  }


Re: Problem with query negation

2012-05-18 Thread Ramprakash Ramamoorthy
On Fri, May 18, 2012 at 7:26 PM, Ahmet Arslan iori...@yahoo.com wrote:

   I don't think request handler should be a problem. I
  have just used the *q
  *parameter as follows.
 
  String q = params.get(CommonParams.Q);
  IndexSchema schema = req.getSchema();
  Query query = new QueryParsing().parseQuery(q, schema);
 
  Hope there shouldn't be a problem with the above!

 Solr converts top level negative query (-field:something) into q=+*:*
 -field:something

 It seems that you are missing that part.

 org.apache.solr.search.QueryUtils

 /** Fixes a negative query by adding a MatchAllDocs query clause.
   * The query passed in *must* be a negative query.
   */
  public static Query fixNegativeQuery(Query q) {
BooleanQuery newBq = (BooleanQuery)q.clone();
newBq.add(new MatchAllDocsQuery(), BooleanClause.Occur.MUST);
return newBq;
  }


Oh thats great :)

Thank you very much! You made my day :)

-- 
With Thanks and Regards,
Ramprakash Ramamoorthy,
Project Trainee,
Zoho Corporation.
+91 9626975420