有没有办法批量添加 ElasticSearch 渗透?

Is there a way to bulk-add ElasticSearch percolations?

我想将我的许多文档扔给大量的过滤器查询(我的查询计数是 6 位数)。我已经找到如何一次对多个文档进行多次渗透,但还没有找到如何一次批量添加多个查询。

根据 documentation,我可以使用以下方式在过滤器中注册查询:

curl -XPUT 'localhost:9200/my-index/.percolator/1' -d '{
    "query" : {
        "match" : {
            "message" : "bonsai tree"
        }
    }
}'

我可以一次性添加很多吗?

由于查询像普通文档一样编入索引,您可以像这样简单地批量添加它们:

curl -s -XPOST localhost:9200/_bulk -d '
{ "index" : { "_index" : "my-index", "_type" : ".percolator", "_id" : "1" } }
{ "query" : { "match" : { "message" : "bonsai tree" } }}
{ "index" : { "_index" : "my-index", "_type" : ".percolator", "_id" : "2" } }
{ "query" : { "match" : { "message" : "abc" } }}
{ "index" : { "_index" : "my-index", "_type" : ".percolator", "_id" : "3" } }
{ "query" : { "match" : { "message" : "def" } }}
{ "index" : { "_index" : "my-index", "_type" : ".percolator", "_id" : "4" } }
{ "query" : { "match" : { "message" : "xyz" } }}
'