0
我想在查詢具有過濾器時使用Ajax從elasticsearch檢索數據。 我正在使用GET。來自彈性搜索過濾查詢的Ajax 400錯誤請求
我的代碼如下:
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
$.ajax({
type: 'GET',
url : 'HOST/tomo2o/shop/_search',
crossDomain: true,
data: JSON.stringify({"query":{"match":{"catlev1":"Motors"}}}),
contentType:'application/json; charset=utf-8',
dataType: 'json',
success: function(data) {
console.log(data);
},
error: function(e) {
console.log(e);
}
});
});
</script>
我做了三件事情的人建議做:
- 字符串化JSON的過濾器
- 設置數據類型爲JSON
- 集內容類型爲application/json
但我還是發現了以下錯誤:
GET HOST/tomo2o/shop/_search?{%22query%22:{%22match%22:{%22catlev1%22:%22Motors%22}}} 400 (Bad Request)
很多感謝的人,按預期工作 – woshitom
真棒,很高興它幫助! – Val