Reputation:
I run a query and get a result in marvel plugin as you see in picture:.
And I want this in my web app with ajax request here is my piece of code
var query = "{'query': {'wildcard': {'heroname': {'value': '*dr*'}}}}";
$.ajax({
url: "http://localhost:9200/dota2/_search?" + query,
dataType: "json",
type: "GET",
success: function (data) {
debugger
alert("Success do your stuff!");
},
error: function (a, b, c) {
debugger
alert("Server Internal Error!");
}
})
Its in success but returns many results.. I cant find reson of that. but I copy the request has been sent from client to elastic and paste it browser then here is json data as response comes my ajax success:
I expect just 1 json data as seem in marvel plugin, but it returns me all datas in index so I think wildcard query ignored but why ? or etc ?
Upvotes: 2
Views: 1039
Reputation: 217474
If you want to pass your search query in the query string in a GET call, you need to pass it in the source
parameter.
$.ajax({
url: "http://localhost:9200/dota2/_search?source=" + query,
... ^
|
add source parameter here
Upvotes: 3