# Records aren't getting queried

**URL:** <https://discuss.elastic.co/t/records-arent-getting-queried/183801>\
**Category:** Elasticsearch\
**Created:** [June 1, 2019, 2:11am UTC](https://discuss.elastic.co/t/records-arent-getting-queried/183801 "2019-06-01T02:11:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![snacks](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@snacks](https://discuss.elastic.co/u/snacks)\
**Post date:** [June 1, 2019, 2:11am UTC](https://discuss.elastic.co/t/records-arent-getting-queried/183801/1 "2019-06-01T02:11:54Z")

</div>

I'm learning programming using a book and it is using elasticsearch with it as a project. I am trying to follow along the book but I am getting stuck querying records after bulk uploading records.

For example, I have the following record (which I get via 127.0.0.1:9200/\_search)

```
{
  "took": 8,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 1,
      "relation": "eq"
    },
    "max_score": 1,
    "hits": [
      {
        "_index": "books",
        "_type": "book",
        "_id": "pg123",
        "_score": 1,
        "_source": {
          "doc": {
            "id": 123,
            "title": "At the Earth's Core",
            "authors": [
              "Burroughs, Edgar Rice"
            ],
            "subjects": [
              "Earth (Planet) -- Core -- Fiction",
              "Science fiction",
              "Adventure stories",
              "Fantasy fiction"
            ]
          }
        }
      }
    ]
  }
}

```

But when I search using this: curl -s -XGET '127.0.0.1:9200/books/book/\_search?q=id:123'  
I get no hits which is not correct. I expected to get the above response.

```
{
  "took": 4,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 0,
      "relation": "eq"
    },
    "max_score": null,
    "hits": []
  }
}

```

Can anyone tell me how to format the query so that it returns the record that I first pasted?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 1, 2019, 2:35am UTC](https://discuss.elastic.co/t/records-arent-getting-queried/183801/2 "2019-06-01T02:35:41Z")

</div>

It's because the field name is not `id` but `doc.id`.

So this should work:

```
curl -s -XGET '127.0.0.1:9200/books/book/_search?q=doc.id:123'
```

---

<div class="post-metadata">

**Author:** ![snacks](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@snacks](https://discuss.elastic.co/u/snacks)\
**Post date:** [June 1, 2019, 2:42am UTC](https://discuss.elastic.co/t/records-arent-getting-queried/183801/3 "2019-06-01T02:42:45Z")

</div>

That worked, thank you so much!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 29, 2019, 2:42am UTC](https://discuss.elastic.co/t/records-arent-getting-queried/183801/4 "2019-06-29T02:42:47Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
