0

I am searching on an element called package, which has the field pkg_scope.

When I add the following string to my query I get 200 results:

AND ( pkg_scope:'Scope Undefined')

When I add the following string instead, I get one result:

AND ( NOT pkg_scope:'Top File')

The one result has a scope 'Scope Undefined'. I think it is reasonable to expect that the second query results would contain the results of the first one. Am I missing something ?

This is the complete query:

 query: *:* AND rectype:'Package' AND isPublic:"Yes" AND ( NOT pkg_scope:'Top File'  )

I am using ES 1.7.1

Giannis
  • 5,286
  • 15
  • 58
  • 113
  • Why would you expect a more restrictive query (one with more required `AND` clauses) would have *more* results? And why are you starting your query with a `*:*`? The query `*:* AND field:term` gets exactly the same results as `field:term`, only slower (unless elasticsearch is smart enough to optimize away the `*:*`, which it might be). – femtoRgon Sep 16 '15 at 15:28
  • Sorry maybe my wording is not correct. The two first queries are interchanged at the end of the last query. – Giannis Sep 16 '15 at 15:32
  • Ah, I see what you mean now. Thanks for clarifying. I believe the problem you are running into is this one: http://stackoverflow.com/questions/16089831/lucene-query-fails-with-mixed-must-must-not/16091066#16091066 I'm a bit confused, though, as to why you are getting any results at all in that case. – femtoRgon Sep 16 '15 at 15:35
  • By the way, for this and other problems [I kinda hate lucene's and/or/not syntax](https://lucidworks.com/blog/why-not-and-or-and-not/). +/- syntax is much better. – femtoRgon Sep 16 '15 at 15:45

1 Answers1

0

The problem was the quotes around the string. For more than one words, double quotes need to be used. So NOT pkg_scope:'Top File' need to be changed to NOT pkg_scope:"Top File"

Giannis
  • 5,286
  • 15
  • 58
  • 113