开发者

Proper snowball analyzer configuration when using Grails Searchable Plugin

开发者 https://www.devze.com 2022-12-28 10:15 出处:网络
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

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
  }


Have you tried putting these settings in Searchable.groovy instead of Config.grovy?

In Searchable.groovy, I have:

    compassSettings = [
    'compass.engine.analyzer.default.type': 'snowball',
    'compass.engine.analyzer.default.name': 'English',
    'compass.engine.analyzer.search.type': 'snowball',
    'compass.engine.analyzer.search.name': 'English',
]

And that seems to work fine for me.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号