ElasticSearch没有失败,但是返回了错误的结果 [英] ElasticSearch not failing but returning incorrect results
问题描述
我在应用程序中使用Ajax切换到POST搜索,因此可以开始使用日期范围.但是,无论我发布什么内容,它始终会返回索引中的前10个结果.真实结果在30k范围内.
I switched to POST searches using ajax in my application so I can start using the date range. However it seems no matter what I post it keeps returning the first 10 results in my index. The true results are in the 30k range.
amplify.request.define("searchPostRequest", "ajax", {
url: "http://leServer:9200/people/person/_search",
type: "POST",
dataType: 'jsonp',
contentType: 'application/json'
});
self.advancedSearchPostQuery = {
query: {
term: {
locationNumber:479
}
}
};
console.log(self.advancedSearchPostQuery);
amplify.request({
resourceId: "searchPostRequest",
data: JSON.stringify(self.advancedSearchPostQuery),
success: function (data) {
console.log(data.hits.hits.length);
}
});
推荐答案
进行更多调试后,我发现请求已作为GET发送,即使我已将其明确设置为发布.将数据类型从jsonp移到json时,可以将请求作为POST发送,从而解决了该问题.但是,这会导致IE中出现问题,因为该请求已发送到另一个域,因此根本没有发送该请求.
After doing more debugging I found that the request was being sent as a GET even though I had explicitly set it to post. Moving the data type to json, from jsonp let the request be sent as a POST, which resolved the issue. However this causes an issue in IE where the request is not sent at all due to the request being sent to another domain.
amplify.request.define("searchPostRequest", "ajax", {
url: "http://leServer:9200/people/person/_search",
type: "POST",
dataType: 'json',
contentType: 'application/json'
});
这篇关于ElasticSearch没有失败,但是返回了错误的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!