0

我是 ES 的新手,我正在尝试弄清楚一些事情。

我用这种方式做了一个基本的查询

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

我得到了这个...

{
  "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...

所以现在我想用 id 获取对象,asdfqwerzcxv我这样做了:

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

        }
    }
}

但当然不工作......我也试图让整个路线像:

GET _search
{
    "query": {
        "match" : {
            "_source" :{
              "readModel" : {
                 "id": "asdfqwerzcxv"      
              }
            }

        }
    }
}

但没有运气...

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

谢谢

4

1 回答 1

1

您需要使用完全限定的字段名称,试试这个:

GET _search
{
    "query": {
        "match" : {
            "readModel.id" :"asdfqwerzcxv"
                 ^
                 |
              add this
        }
    }
}
于 2018-11-28T14:05:25.397 回答