2

I want to throw my many documents to a LOT of percolator queries (my query count is in the 6-digit). I've found how to multi-percolate many documents at once, but haven't found how to bulk-add many queries at once.

According to the documentation, I can register a query in the percolator using:

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

Can I add many of these in one fell swoop?

4

1 回答 1

5

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

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" } }}
'
于 2015-06-15T14:10:56.417 回答