【问题标题】:Is there a way to bulk-add ElasticSearch percolations?有没有办法批量添加 ElasticSearch 渗透?
【发布时间】:2015-06-15 22:10:56
【问题描述】:

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

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

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

我可以一口气添加很多吗?

【问题讨论】:

标签: elasticsearch elasticsearch-percolate


【解决方案1】:

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

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" } }}
'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-02-13
    • 2021-09-15
    • 2013-07-23
    • 1970-01-01
    • 2021-05-18
    • 2021-10-01
    • 1970-01-01
    • 2020-04-21
    相关资源
    最近更新 更多