Hi Donal,

I'm not familiar with Compass annotations, so forgive my ignorance, but it's 
not clear to me what your documents look like, or how a Lucene document 
corresponds to your objects.

What does the document you get as a hit when you search look like?  That is, 
what fields are defined on it?

When you look in Luke, what do you see?  Are the documents heterogeneous?  That 
is, do some documents have different fields defined on them than others?

Also, you wrote:
> The only reason I was using "AND" in my query, was to be explicit about
> how the predicates should be combined, rather than relying on the
> default (which is in fact "AND").

What you're missing is that Lucene's query syntax does not exactly incorporate 
Boolean logic.  See 
<http://lucene.apache.org/java/2_4_1/queryparsersyntax.html#Boolean%20operators>
 for more information; also, there is a discussion on the Lucene wiki that may 
be useful to you: <http://wiki.apache.org/lucene-java/BooleanQuerySyntax>.  In 
particular, using the "+" operator in front of a term means that it MUST be 
present; a match will not occur unless the specified field with a term matching 
the specified value is present on a document.

So, somehow, the hit you're getting (even though you don't think you should be) 
matches *both* courseName:cooking and mandatory:Y.

That is, your problem is one of document structure, not query syntax.  I 
suspect you'll need to further investigate how Compass annotations affect 
document structure to resolve this issue.

Steve

Reply via email to