From d1969a1d3e643f672cfe1b2ecde5bcac047337e1 Mon Sep 17 00:00:00 2001 From: Mahesh Yellai Date: Fri, 24 Oct 2014 19:02:02 +0530 Subject: [PATCH] Use GET of elasticsearch client --- package.json | 2 +- src/elasticsearch-adapter.coffee | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index d22bb82..1a9f004 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pirate", - "version": "0.9.10", + "version": "0.9.11", "description": "A simple storage interface with adapters for different storage systems", "main": "lib/index.js", "directories": { diff --git a/src/elasticsearch-adapter.coffee b/src/elasticsearch-adapter.coffee index 2c4a438..75e98dd 100644 --- a/src/elasticsearch-adapter.coffee +++ b/src/elasticsearch-adapter.coffee @@ -106,16 +106,13 @@ class Collection extends BaseCollection match "object", (query) -> @events.source (events) => events.safely => - @adapter.client.search( - @index, @type, {filter: {term: query}} - ) + @adapter.client.get(@index, @type, query._id) .on "data", (data) -> jsonData = JSON.parse(data) unless jsonData.error? - if jsonData.hits? and jsonData.hits.hits? and jsonData.hits.hits.length == 1 - result = jsonData.hits.hits[0]._source - result._id = jsonData.hits.hits[0]._id - result.score = jsonData.hits.hits[0]._score + if jsonData._source? + result = jsonData._source + result._id = jsonData._id else result = null events.emit "success", result