我使用的是grail的searchable plugin(0.6.4)
。我需要根據隱私設置搜索會員。以下是db設計。 會員有MemberProfile, and MemberProfile has PrivacySettings
Grails可搜索插件(Lucene) - 1對多查詢
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的display_name的成員。
我想這樣的事情
def query="mydisplayname"
def searchResults = Member.search(query + "*" + " +(fieldSectionName:${'display_name'} AND connectionLevel:${true})", params)
那不是我所問的。感謝您的回覆 – 2013-09-13 10:00:10