Elasticsearch: CURL To Ajax Request
I am using Ajax request for elasticsearch to get search results. Finally, I have found the query which I have to go for. (This is a follow up question to link) Here is the query in
Solution 1:
From my experience the behavior of GET methods with a body is sometimes hard to predict. Actually, elastic search supports GET with body but I also had some strange results depending on the configuration of the servers, proxies and so on... The documentation even highlights the problems with javascript (search with GET).
Usually, using POST instead of GET helps to resolve these problems or at least to have a further debug option.
Solution 2:
For those coming from Google, another way to solve this problem - or even if the POST
solution doesn't work - is to use source
parameter in the URL, as mentioned in docs[1].
$.ajax({
type: "GET",
url: "http://localhost:9200/firebase/_search?source_content_type=application/json&source=" + JSON.stringify(query),
contentType: 'application/json',
success: searchSuccess,
dataType: 'json'
});
Post a Comment for "Elasticsearch: CURL To Ajax Request"