# Unable to find document on \_id in elasticsearch mongodb

**URL:** <https://discuss.elastic.co/t/unable-to-find-document-on--id-in-elasticsearch-mongodb/45071>\
**Category:** Elasticsearch\
**Created:** [March 22, 2016, 6:42am UTC](https://discuss.elastic.co/t/unable-to-find-document-on--id-in-elasticsearch-mongodb/45071 "2016-03-22T06:42:37Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Satyadeep\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/satyadeep_kumar/32/8589_2.png) [@Satyadeep\_Kumar](https://discuss.elastic.co/u/Satyadeep_Kumar)\
**Post date:** [March 22, 2016, 6:42am UTC](https://discuss.elastic.co/t/unable-to-find-document-on--id-in-elasticsearch-mongodb/45071/1 "2016-03-22T06:42:37Z")

</div>

I am trying to lookup a mongodb document based on its \_id in elasticsearch using php-2.0 api of elasticsearch. It is giving me error

```
[2016-03-22 01:38:34,672][DEBUG][action.search.type] [Cameron Hodge] [smartjn][1], node[rMZbhVr7R-ezCeg2DeirLQ], [P], v[4], s[STARTED], a[id=q1AbfdiHTN6RqA2p_DTw8g]: Failed to execute [org.elasticsearch.action.search.SearchRequest@55c6bb7d] lastShard [true]
RemoteTransportException[[Cameron Hodge][127.0.0.1:9300][indices:data/read/search[phase/query]]]; nested: SearchParseException[failed to parse search source [{"query":{"match":{"uid":{}}}}]]; nested: QueryParsingException[No text specified for text query];
Caused by: SearchParseException[failed to parse search source [{"query":{"match":{"uid":{}}}}]]; nested: QueryParsingException[No text specified for text query];

```

The code is

```
require 'vendor/autoload.php';
$userId = new MongoDB\BSON\ObjectId($userID);

$client2 = Elasticsearch\ClientBuilder::create()->build();
                       $params = [
    'index' => 'smartjn',
    'type' => 'user_master',
    'body' => [
        'query' => [
                'match' => ['_id' => $userId]
                  ]
              ]
        ];
$results2 = $client2->search($params);

```

Any pointers on what am I doing wrong?

Thanks

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [March 22, 2016, 7:29am UTC](https://discuss.elastic.co/t/unable-to-find-document-on--id-in-elasticsearch-mongodb/45071/2 "2016-03-22T07:29:11Z")

</div>

> [@Satyadeep\_Kumar](#):
>
> {"query":{"match":{"uid":{}}}}

I don't know PHP, but it doesn't look like your ID is being passed in.

---

<div class="post-metadata">

**Author:** ![Satyadeep\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/satyadeep_kumar/32/8589_2.png) [@Satyadeep\_Kumar](https://discuss.elastic.co/u/Satyadeep_Kumar)\
**Post date:** [March 22, 2016, 7:34am UTC](https://discuss.elastic.co/t/unable-to-find-document-on--id-in-elasticsearch-mongodb/45071/3 "2016-03-22T07:34:15Z")

</div>

Hi @warkolm , sorry I pasted an old log , the recent one is

```
[2016-03-22 03:32:33,483][DEBUG][action.search.type] [Cameron Hodge] [smartjn][1], node[rMZbhVr7R-ezCeg2DeirLQ], [P], v[4], s[STARTED], a[id=q1AbfdiHTN6RqA2p_DTw8g]: Failed to execute [org.elasticsearch.action.search.SearchRequest@2b7ced36] lastShard [true]
RemoteTransportException[[Cameron Hodge][127.0.0.1:9300][indices:data/read/search[phase/query]]]; nested: SearchParseException[failed to parse search source [{"query":{"match":{"_id":{}}}}]]; nested: QueryParsingException[No text specified for text query];
Caused by: SearchParseException[failed to parse search source [{"query":{"match":{"_id":{}}}}]]; nested: QueryParsingException[No text specified for text query];

```

Thanks

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [March 22, 2016, 7:34am UTC](https://discuss.elastic.co/t/unable-to-find-document-on--id-in-elasticsearch-mongodb/45071/4 "2016-03-22T07:34:33Z")

</div>

It's still the same error.

---

<div class="post-metadata">

**Author:** ![Satyadeep\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/satyadeep_kumar/32/8589_2.png) [@Satyadeep\_Kumar](https://discuss.elastic.co/u/Satyadeep_Kumar)\
**Post date:** [March 22, 2016, 7:40am UTC](https://discuss.elastic.co/t/unable-to-find-document-on--id-in-elasticsearch-mongodb/45071/5 "2016-03-22T07:40:30Z")

</div>

Yes the error is same, and I am trying to understand the error behind it , and how to rectify it.

Thanks

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [March 22, 2016, 8:00am UTC](https://discuss.elastic.co/t/unable-to-find-document-on--id-in-elasticsearch-mongodb/45071/6 "2016-03-22T08:00:11Z")

</div>

Like I said, your ID isn't being passed to ES in the query, so I'd start by making sure your code does that.

---

<div class="post-metadata">

**Author:** ![Satyadeep\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/satyadeep_kumar/32/8589_2.png) [@Satyadeep\_Kumar](https://discuss.elastic.co/u/Satyadeep_Kumar)\
**Post date:** [March 22, 2016, 9:03am UTC](https://discuss.elastic.co/t/unable-to-find-document-on--id-in-elasticsearch-mongodb/45071/7 "2016-03-22T09:03:28Z")

</div>

silly mistake from my side , just passed the id as String without converting it to BSON object.

Thank you all.

---

<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:** [July 5, 2017, 11:06pm UTC](https://discuss.elastic.co/t/unable-to-find-document-on--id-in-elasticsearch-mongodb/45071/8 "2017-07-05T23:06:22Z")

</div>


