如何进行适当的查询以通过ID选择并随后使用弹性搜索进行更新?

时间:2018-11-28 14:02:12

标签: elasticsearch

我在ES领域非常陌生,我正在尝试找出一些东西。

我以此方式进行了基本查询

sapply(strsplit(vector, ""), function(x) {
   inds = rle(x)
   max(inds$lengths[inds$values == "X"])
})

#[1] 4 1 2 1 2 1 2 1 2 2 3 2

我知道了...

GET _search
{
  "query": {
    "match_all": {}
  }
}

所以现在我想获取ID为{ "took": 7, "timed_out": false, "_shards": { "total": 768, "successful": 768, "failed": 0 }, "hits": { "total": 456, "max_score": 1, "hits": [ { "_index": "sometype_1", "_type": "sometype", "_id": "12312321312312", "_score": 1, "_source": { "readModel": { "id": "asdfqwerzcxv", "status": "active", "hidden": false }, "model": { "id": "asdfqwerzcxv", "content": { "objectId": "421421312312", "message": "hello world", ..... //the rest of the object... 的对象,并且这样做:

asdfqwerzcxv

但是当然不起作用...我也试图使整个路线像这样:

GET _search
{
    "query": {
        "match" : {
            "id" :"asdfqwerzcxv"

        }
    }
}

但是没有运气...

有没有办法做到这一点?有人可以帮我吗?

谢谢

1 个答案:

答案 0 :(得分:1)

您需要使用标准字段名,请尝试以下操作:

GET _search
{
    "query": {
        "match" : {
            "readModel.id" :"asdfqwerzcxv"
                 ^
                 |
              add this
        }
    }
}