繁体   English   中英

Grails可搜索插件(Lucene)-1对多查询

[英]Grails Searchable Plugin(Lucene) - 1 To Many Query

我正在使用grail的searchable plugin(0.6.4) 我需要根据隐私设置搜索会员。 以下是数据库设计。 成员具有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
}

一个成员个人资料的每个字段都有许多隐私设置。

什么将是查询,以仅搜索在隐私设置表的fieldsSectionName和connectionLevel为true的那些成员。

我正在尝试这样的事情

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

我不知道这件事,但是在Lucene中,布尔查询中子句的最大数量默认为1024。

您可以增加此限制。

但是,这将导致性能下降。 或者,您可以为文档中的值建立索引并进行搜索(lucene将对具有相同名称的不同字段执行“或”操作)。

您可以使用BooleanQuery类的静态属性来更改限制:

 BooleanQuery.MaxClauseCount = 99999;

奥姆里

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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