我很挣扎,如何使用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}
答案 0 :(得分: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"}}]}
答案 1 :(得分:0)
这是正确的陈述 -
client.ingest.put_pipeline :id => 'attachment', :body => {description: "Extract attachment information", processors: [{ attachment: { field: 'document_content', indexed_chars: '-1'}}]}