我創建了一個基本的應用程序(Grails的1.3.5,檢索0.5.5.1)與你的兩個類和搜索:我的作品「國家NL」。您是否記得在嘗試搜索之前調用index()?
grails create-app search
grains install-plugin searchable
人:
class Person {
static searchable = {
address component: true
}
Address address
}
地址:
class Address {
static belongsTo = Person
static searchable = {
root false
}
String country
}
引導:
class BootStrap {
def init = { servletContext ->
def p1 = new Person(address:new Address(country:'NL')).save()
def p2 = new Person(address:new Address(country:'DE')).save()
def p3 = new Person(address:new Address(country:'NZ')).save()
Person.index()
}
def destroy = {
}
}
然後我瀏覽到到/搜索和搜索國家:NL,得到了人1個返回。
如果你想看到什麼檢索在幕後做至於田/索引,等等 - 盧克是一個非常方便的工具(只需下載可執行的JAR文件):http://code.google.com/p/luke/
索引文件是
<user.home>/.grails/projects/<project name>/searchable-index/development/index
歡呼
李
你舉的例子聽起來完全像我沒有料到它的工作,但對我來說沒有。 (簡單的搜索可以工作,所以這不是問題。)我會給盧克一個嘗試,看看它是否被索引。我想很高興知道這實際上應該像我預期的那樣工作。現在弄清楚爲什麼它不適合我的項目。 – mcv 2010-10-12 12:57:04