fullscale / elastic.js

A JavaScript implementation of the elasticsearch Query DSL
http://docs.fullscale.co/elasticjs/
MIT License
654 stars 163 forks source link

Angular client is double serializing the query #11

Closed ghost closed 11 years ago

ghost commented 11 years ago

In the elastic.js, you serialize the query using JSON.stringify, but Angular does the same thing when passing the data through it, so for example when I try to do a simple query like this.

var results = ejs.Request() .indices('refdata') .size(15) .doSearch();

The query gets sent over as {\"size\": 15}, which elastic doesn't understand. I can fix it by adding JSON.parse on the elastic-engular-client file, but the double serialization seems unnecessary.

ghost commented 11 years ago

Hmm, this seems to be an issue due to using the config object instead of the $http.post methods, if I roll back my changes it does not double serialize.

ghost commented 11 years ago

OK, this was a problem on my end, typically from Angular's docs, if you use transformRequest, you are responsible for doing JSON.stringify on the data, so my prior transformRequest function did that and caused the double serialization, if I just return what's already passed it works fine.