简体   繁体   中英

Grails Searchable Plugin(Lucene) - 1 To Many Query

I am using grail's searchable plugin(0.6.4) . I need to search the Members on the basis of privacy settings. Following is the db design. Member has MemberProfile, and MemberProfile has PrivacySettings

class Member extends {
        String firstName
        String lastName
    static searchable = {
        analyzer "simple"
        only = ['firstName', 'lastName']
        firstName boost: 5.0
        profile component: true
        profile reference: true
    }
    static hasOne = [profile: MemberProfile]
}
class MemberProfile {
    static searchable = {
        analyzer "simple"
        only = ['currentCity', 'currentCountry']
        privacySettings component: true
    }

        static hasMany = [privacySettings:PrivacySettings]
    String currentCity
    String currentCountry
    List<PrivacySettings> privacySettings
}
//For instance Privacy Settings contains 
//fieldSectionName: firstName , connectionLevel: true , memberLevel: false
// This means firstName will be shown to only members' friends(connection)
class PrivacySettings {

    static searchable = {
        analyzer "simple"
        only = ['fieldSectionName', 'connectionLevel', 'memberLevel']
    }
    String fieldSectionName
    boolean connectionLevel
    boolean memberLevel
}

One member profile has many privacy settings for each field.

What will be the query to search only those members which have display_name in fieldsSectionName and connectionLevel true in the privacy settings table.

I am trying something like this

def query="mydisplayname"
def searchResults = Member.search(query + "*" + "  +(fieldSectionName:${'display_name'} AND connectionLevel:${true})", params)

I don't know grail but in Lucene the maximum number of clauses in a boolean query is 1024 by default.

You can increase this limit.

There would be performance penalty, though. or you can index the values on the document and search for them (lucene will do an OR operation on different fields with the same name).

You can change the limit using a static property on BooleanQuery class:

 BooleanQuery.MaxClauseCount = 99999;

Omri

我在grails应用程序中遇到了同样的问题,要解决该问题,请将org.apache.lucene.search.BooleanQuery.maxClauseCount = 99999添加到您的config.groovy中,然后重新启动应用程序

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM