使用 Grails Searchable Plugin 时正确的雪球分析器配置

发布于 2024-08-30 18:19:05 字数 1183 浏览 4 评论 0原文

为了改进词干分析,我们希望从默认分析器切换到滚雪球式,但是,在正确的设置方面遇到很多困难,并且希望得到任何帮助。在

环境中: - 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

℉絮湮 2024-09-06 18:19:05

您是否尝试过将这些设置放入 Searchable.groovy 而不是 Config.grovy 中?

在 Searchable.groovy 中,我有:

    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',
]

这似乎对我来说效果很好。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文