使用 Grails Searchable Plugin 时正确的雪球分析器配置
为了改进词干分析,我们希望从默认分析器切换到滚雪球式,但是,在正确的设置方面遇到很多困难,并且希望得到任何帮助。在
环境中: - Sun 的 Java 1.6.16 - Grails 1.2.2 - 可搜索插件 0.5.5
Config.groovy: 已尝试这两种设置:
compassSettings = ['compass.engine.analyzer.stemmed.type': 'snowball',
'compass.engine.analyzer.stemmed.name': 'English']
compassSettings = ['compass.engine.analyzer.snowball.type': 'snowball',
'compass.engine.analyzer.snowball.name': 'English',
'compass.engine.analyzer.search.type': 'snowball',
'compass.engine.analyzer.search.name': 'English']
Search.groovy - 调用:
def searchResult = searchableService.search(params.q, withHighlighter: {
highlighter, index, sr
if (!sr.highlights) {
sr.highlights = []
}
try {
sr.highlights[index] = highlighter.fragments("content")[0..2].join(" ")
} catch (IndexOutOfBoundsException ex) {
sr.highlights[index] = highlighter.fragment("content")
}
})
def suggestion = searchableService.suggestQuery(params.q)
if (suggestion != params.q) {
searchResult.suggestedQuery = suggestion
}
To improve stemming we want to switch from the default analyzer to snowball, however, having a lot of difficulty with the proper settings and would appreciate any help. In
Environment:
- Sun's Java 1.6.16
- Grails 1.2.2
- Searchable Plug-In 0.5.5
Config.groovy:
Have tried both settings:
compassSettings = ['compass.engine.analyzer.stemmed.type': 'snowball',
'compass.engine.analyzer.stemmed.name': 'English']
compassSettings = ['compass.engine.analyzer.snowball.type': 'snowball',
'compass.engine.analyzer.snowball.name': 'English',
'compass.engine.analyzer.search.type': 'snowball',
'compass.engine.analyzer.search.name': 'English']
Search.groovy - The Invocation:
def searchResult = searchableService.search(params.q, withHighlighter: {
highlighter, index, sr
if (!sr.highlights) {
sr.highlights = []
}
try {
sr.highlights[index] = highlighter.fragments("content")[0..2].join(" ")
} catch (IndexOutOfBoundsException ex) {
sr.highlights[index] = highlighter.fragment("content")
}
})
def suggestion = searchableService.suggestQuery(params.q)
if (suggestion != params.q) {
searchResult.suggestedQuery = suggestion
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过将这些设置放入 Searchable.groovy 而不是 Config.grovy 中?
在 Searchable.groovy 中,我有:
这似乎对我来说效果很好。
Have you tried putting these settings in Searchable.groovy instead of Config.grovy?
In Searchable.groovy, I have:
And that seems to work fine for me.