Grails 2.3.3和Solr

时间:2013-12-01 11:14:08

标签: grails solr grails-2.3

我正在尝试将Grails 2.3.3与Solr一起使用。我已经安装了插件:

grails.project.dependency.resolution = {
    plugins {
        ...
        compile ":solr:0.2"
    }
}

和(已弃用):

$> grails install-plugin solr

但它不起作用。这个插件是否仍然有效,或者还有其他替代方法可以将Solr与Grails 2.3.3一起使用?

1 个答案:

答案 0 :(得分:0)

我认为此插件上的开发可能处于非活动状态。出于兴趣,我非常成功地使用了Searchable:

BuildConfilg.groovy:

plugins { ...
    compile ":searchable:0.6.6"

在您的域类中:

class Article {
   String headline
   String extract

   static searchable = {
      only = ['headline', 'extract']
      headline boost: 2.0, spellCheck: 'include'
      extract boost: 1.7, spellCheck: 'include'
    }
    ...
 }

要在服务中编入索引:

def searchableService
 ...

     searchableService.index()


}

编辑:

如果您拼写错误搜索字词,拼写检查会添加工具以提供建议的搜索:

 def suggestedQuery = searchableService.suggestQuery(searchTerm)

搜索术语

 def searchResult = searchableService.search("dog", options)

要匹配类似的单词“cycle”或“cycling”,请附加到serach术语

 def searchResult = searchableService.search("cycle~", options)

此处的选项还允许您在结果中突出显示搜索词

 options.withHighlighter = textHighlighter
相关问题