Hi, I tried your suggestion:
"+courseName:cooking +mandatory:Y" but it still matches the student who attends a non-mandatory cooking course, and another mandatory course, which is not what I want. 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"). Incidentally, I also posted a description of my problem to stackoverflow. The most useful response I got was: "What you are trying to do is sometimes known as "scoped search" or "xml search" - the ability to search based on a set of related sub-elements. Lucene does not support this natively but there are some tricks you can do to get it to work. You can put all of the course data associated with a student in a single field. Then bump the term position by a fixed amount (like 100) between the terms for each course. You can then do a proximity search with phrase queries or span queries to force a match for attributes of a single course. This is how Solr supports multi-valued fields." So it seems like Lucene simply doesn't support this kind of query. This is surprising to me, but based on my experience over the last few days, it appears to be true. I've tried using Luke to check the data in the index, but I'm not entirely sure what to look for. Any help you could provide with this would be much appreciated. Cheers, Don