Node.js driver proper search?

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

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

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?

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

Cheers

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.

Hello mastayoda,

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

Thanks