lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lukáš Vlček <lukas.vl...@gmail.com>
Subject Re: Querying across object relationships
Date Thu, 30 Jul 2009 15:50:24 GMT
Hi,

this is interesting but why do you use "AND" in your query when both the
term are a MUST (they have +). See
http://lucene.apache.org/java/2_4_1/queryparsersyntax.html for more details
about Lucene query syntax.

Try dropping the AND and try the following query:
+courseName:cooking +mandatory:Y
This query means that both the terms must be met.

If this does not work check that the default operator is set to AND and also
you can directly check what data is in your index (using Luke for example).

Let me know if this helps.

Regards,
Lukas

http://blog.lukas-vlcek.com/


On Thu, Jul 30, 2009 at 4:10 PM, Donal Murtagh <domurtag@yahoo.co.uk> wrote:

> Hi Phil,
>
> I don't really have any query parsing/generation code to send you, because
> I'm not using Lucene directly. I'm using the Grails Searchable Plugin,
> which builds on both Lucene and Compass. The only relevant information
> I can give you is my Grails domain classes which show how I've mapped
> my classes to the Lucene search index.
>
> @Searchable
> class Student {
>
>    @SearchableProperty(accessor = 'property')
>    String name
>
>    static hasMany = [attendances: Attendance]
>
>    @SearchableId(accessor = 'property')
>    Long id
>
>    @SearchableComponent
>    Set<Attendance> getAttendances() {
>        return attendances
>    }
> }
>
> @Searchable(root = false)
> class Attendance {
>
>     static searchable = true
>     static belongsTo = [student: Student, course: Course]
>
>    @SearchableProperty(accessor = 'property')
>    String mandatory = "Y"
>
>    @SearchableId(accessor = 'property')
>    Long id
>
>    @SearchableComponent
>    Course getCourse() {
>        return course
>    }
> }
>
> @Searchable(root = false)
> class Course {
>
>    @SearchableProperty(accessor = 'property', name = "courseName")
>    String name
>
>    @SearchableId(accessor = 'property')
>    Long id
> }
>
> In order to execute a search I simply provide a Lucene query string such as
> "+courseName:cooking AND +mandatory:Y"
>
> Cheers,
> Don
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message