【问题标题】:Grails Searchable Plugin(Lucene) - 1 To Many QueryGrails Searchable Plugin(Lucene) - 一对多查询
【发布时间】:2013-03-11 07:09:29
【问题描述】:

我正在使用 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 中具有 display_name 并且在隐私设置表中 connectionLevel 为 true 的成员的查询是什么。

我正在尝试这样的事情

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

【问题讨论】:

    标签: lucene grails-2.0 compass-lucene grails-searchable


    【解决方案1】:

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

    您可以提高此限制。

    但会有性能损失。或者您可以索引文档上的值并搜索它们(lucene 将对具有相同名称的不同字段进行 OR 操作)。

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

     BooleanQuery.MaxClauseCount = 99999;
    

    暗里

    【讨论】:

      【解决方案2】:

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

      【讨论】:

      • 这不是我问的。感谢您的回复
      猜你喜欢
      • 1970-01-01
      • 2012-11-23
      • 1970-01-01
      • 2013-02-22
      • 2014-12-06
      • 2013-03-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多