【问题标题】:How to create ingest pipeline in elasticsearch using elasticsearch-ruby gem如何使用elasticsearch-ruby gem在elasticsearch中创建摄取管道
【发布时间】:2018-10-07 07:03:30
【问题描述】:

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

对于这个电话 -

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

这是我得到的例外 -

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}

【问题讨论】:

  • 请展示你到目前为止所做的事情
  • @Val - 我已更新问题并正在寻找此请求的方法。
  • 你试过client.ingest.put_pipeline :id =&gt; 'attachment', :body =&gt; {....}吗?
  • @Val,我已经尝试过你建议我的方法,但我遇到了一个例外。我已经更新了这个问题,但有例外。请看一看。
  • 您没有正确粘贴正文。请参阅下面的答案

标签: elasticsearch elasticsearch-ruby


【解决方案1】:

错误状态

[processors] 属性不是列表,而是 [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"}}]}

【讨论】:

  • 酷,很高兴它有帮助!
  • 谢谢@Val,你知道吗,如何使用 elasticsearch ruby​​ 在附件管道中使用文档?我没有找到任何方法。
  • 随意创建另一个问题来描述您的问题。
  • 我发布了一个新问题。请审查它。谢谢@Val
【解决方案2】:

这是正确的说法 -

client.ingest.put_pipeline :id =&gt; 'attachment', :body =&gt; {description: "Extract attachment information", processors: [{ attachment: { field: 'document_content', indexed_chars: '-1'}}]}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多