# Node.js driver proper search?

**URL:** <https://discuss.elastic.co/t/node-js-driver-proper-search/56410>\
**Category:** Elasticsearch\
**Created:** [July 26, 2016, 3:06pm UTC](https://discuss.elastic.co/t/node-js-driver-proper-search/56410 "2016-07-26T15:06:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mastayoda](https://avatars.discourse-cdn.com/v4/letter/m/a183cd/32.png) [@mastayoda](https://discuss.elastic.co/u/mastayoda)\
**Post date:** [July 26, 2016, 3:06pm UTC](https://discuss.elastic.co/t/node-js-driver-proper-search/56410/1 "2016-07-26T15:06:45Z")

</div>

Hello everyone,

I'm trying to make a simple search using elasticsearch 2.3.4 using the Node.js driver.

The problem is the following:

I have severa; documents stored in the engine, some look like:

{  
index: 'mygraph',  
type: 'edge',  
id: '1',  
body: {  
relation: 'knows',  
source: 1,  
target: 2  
}  
}

If I go to the browser and execute this URL: **[http://localhost:8004/mygraph/edge/\_search?q=relation%3Aknows](http://localhost:8004/mygraph/edge/_search?q=relation%3Aknows)**

I get:

{  
"took": 5,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 1,  
"max\_score": 1.0,  
"hits": [{  
"\_index": "mygraph",  
"\_type": "edge",  
"\_id": "1",  
"\_score": 1.0,  
"\_source": {  
"relation": "knows",  
"source": 1,  
"target": 2  
}  
}]  
}  
}

Then if I do the same in the Node.js driver(which is the same POST request shwoing in the trace):

Elasticsearch TRACE: 2016-07-26T15:00:01Z  
-\> POST [http://localhost:8004/mygraph/edge/\_search?q=relation%3Aknows](http://localhost:8004/mygraph/edge/_search?q=relation%3Aknows)

I get:

{  
"took": 2,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 0,  
"max\_score": null,  
"hits": []  
}  
}

Somebody can tell me what is wrong?

---

<div class="post-metadata">

**Author:** ![thiago](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago/32/32096_2.png) [@thiago](https://discuss.elastic.co/u/thiago)\
**Post date:** [July 26, 2016, 4:18pm UTC](https://discuss.elastic.co/t/node-js-driver-proper-search/56410/2 "2016-07-26T16:18:46Z")

</div>

Hello mastayoda,

The second request should work IF it has an empty body.

What I don't understand is, if you are using the official nodejs driver, why are you performing an URI search from nodejs?

If using the official driver, you should be doing something like described here: [https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-search](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-search)

Cheers

---

<div class="post-metadata">

**Author:** ![mastayoda](https://avatars.discourse-cdn.com/v4/letter/m/a183cd/32.png) [@mastayoda](https://discuss.elastic.co/u/mastayoda)\
**Post date:** [July 26, 2016, 4:32pm UTC](https://discuss.elastic.co/t/node-js-driver-proper-search/56410/3 "2016-07-26T16:32:39Z")

</div>

Hello Thiago\_Suoza,

I'm using the official driver, the URI is the log trace the official drivers shows when I execute the search. It is weird the doing it directly in the browser works but not via the driver. I don't know what is happening.

---

<div class="post-metadata">

**Author:** ![thiago](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago/32/32096_2.png) [@thiago](https://discuss.elastic.co/u/thiago)\
**Post date:** [July 27, 2016, 5:31pm UTC](https://discuss.elastic.co/t/node-js-driver-proper-search/56410/4 "2016-07-27T17:31:11Z")

</div>

Hello mastayoda,

Please, paste the nodejs code snippet instantiates the elasticsearch client and performs this search.

Thanks

---

<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, 10:32pm UTC](https://discuss.elastic.co/t/node-js-driver-proper-search/56410/5 "2017-07-05T22:32:24Z")

</div>


