Elasticsearch Grails 插件:如何索引文件?

Elasticsearch Grails Plugin: How to index files?

是否可以通过 elasticsearch grails 插件上传和索引 文件?

我的 elasticsearch 服务器中安装了 https://github.com/elastic/elasticsearch-mapper-attachments 插件。

Elasticsearch grails 文档http://noamt.github.io/elasticsearch-grails-plugin/ 没有提到文件映射。

域 class 可能如下所示:

class Document {
     String filecontent

     static searchable = {
       only = ["filecontent"]
       filecontent attachment:true
      }
}

其中 filecontent 是 base64 编码的文件。 实际上这可行,但我无法使突出显示工作。

只要您使用 static search 字段创建或更新任何域实例,弹性搜索插件就会为您做到这一点。

但是如果你想强制执行它,你可以在临时操作中注入 bean elasticSearchService 并调用它的 index() 方法。

这将为您的实例编制索引。

http://noamt.github.io/elasticsearch-grails-plugin/ref/ElasticSearchService/index.html

目前无法使用 elasticsearch-grails-plugin 的标准索引映射来突出显示上传的内容。

我在这里解释了一个解决方法:https://github.com/noamt/elasticsearch-grails-plugin/issues/131