![](/img/trans.png)
[英]Lucene /Searchable Plugin - Grails not reindexing has many
[英]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.