0

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

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

和(已弃用):

$> grails install-plugin solr

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

4

1 回答 1

0

I think development might be inactive on this plugin. Out of interested I use Searchable very successfully:

BuildConfilg.groovy:

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

In your domain class:

class Article {
   String headline
   String extract

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

To index in a Service:

def searchableService
 ...

     searchableService.index()


}

Edit:

The spellcheck add the facility to provide suggested searches if you misspelled the search term:

 def suggestedQuery = searchableService.suggestQuery(searchTerm)

To search for a term

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

To match with similar word "cycle" or "cycling" append ~ on to the serach term

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

The options here also allow you to highlight search terms in the result

 options.withHighlighter = textHighlighter
于 2013-12-01T11:31:27.620 回答