elasticsearch - 如何使用elasticsearch-ruby gem在Elasticsearch中创建摄取管道

标签 elasticsearch elasticsearch-ruby

我很挣扎,如何使用elasticsearch-ruby gem创建摄取附件管道?

对于此电话-

PUT _ingest/pipeline/attachment
{
  "description" : "Extract attachment information",
  "processors" : [
    {
      "attachment" : {
        "field" : "data"
      }
    }
  ]
}

这是我得到的异常(exception)-
2.2.5 :008 > client.ingest.put_pipeline({id: 'attachment', body: {description: "Extract attachment information", processors: { attachment: { field: 'document_content', indexed_chars: '-1', indexed_chars_field: "max_size"}}}})
2018-04-27 08:22:07 +0530: PUT http://localhost:9200/_ingest/pipeline/attachment [status:400, request:0.108s, query:N/A]
2018-04-27 08:22:07 +0530: > {"description":"Extract attachment information","processors":{"attachment":{"field":"document_content","indexed_chars":"-1","indexed_chars_field":"max_size"}}}
2018-04-27 08:22:07 +0530: < {"error":{"root_cause":[{"type":"parse_exception","reason":"[processors] property isn't a list, but of type [java.util.HashMap]","header":{"property_name":"processors"}}],"type":"parse_exception","reason":"[processors] property isn't a list, but of type [java.util.HashMap]","header":{"property_name":"processors"}},"status":400}
2018-04-27 08:22:07 +0530: [400] {"error":{"root_cause":[{"type":"parse_exception","reason":"[processors] property isn't a list, but of type [java.util.HashMap]","header":{"property_name":"processors"}}],"type":"parse_exception","reason":"[processors] property isn't a list, but of type [java.util.HashMap]","header":{"property_name":"processors"}},"status":400}
Elasticsearch::Transport::Transport::Errors::BadRequest: [400] {"error":{"root_cause":[{"type":"parse_exception","reason":"[processors] property isn't a list, but of type [java.util.HashMap]","header":{"property_name":"processors"}}],"type":"parse_exception","reason":"[processors] property isn't a list, but of type [java.util.HashMap]","header":{"property_name":"processors"}},"status":400}

最佳答案

错误状态

[processors] property isn't a list, but of type [java.util.HashMap]



在REST调用中,您正确无误,因为processors是一个数组,但是在ruby调用中,您将其设置为哈希。

所以正确的方法是这样的:
 client.ingest.put_pipeline :id => 'attachment', :body => {description: "Extract attachment information", processors: [{ attachment: { field: 'document_content', indexed_chars: '-1', indexed_chars_field: "max_size"}}]}

关于elasticsearch - 如何使用elasticsearch-ruby gem在Elasticsearch中创建摄取管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50045373/

相关文章:

ruby-on-rails - Faraday::Elasticsearch 的 SSLError

elasticsearch - Elasticsearch排名短/相关标题少

python Elasticsearch : how do you enable curl logging?

elasticsearch - 对可选字段不存在的Elasticsearch查询

elasticsearch - elasticsearch云-访问config/elasticsearch.yml文件

java - 使用 Java API 的 Elasticsearch 复杂查询

ruby-on-rails - 在Ruby中使用 Elasticsearch gem时在哪里指定集群详细信息

elasticsearch - 使用must和match过滤 Elasticsearch 结果,得到意外结果

php - Elasticsearch Prefixfilter特殊字符不起作用