我一直试图弄清楚如何使用jQuery AJAX调用正确地从elasticsearch请求数据.我要么得到一个解析错误,要么我将得到我正在搜索的索引中的每个文档.
$(document).ready(function() {
var timer = null;
function dicom_search() {
var box = $('#s_box').val();
$.ajax({
url: 'http://localhost:9200/dicoms/dicoms/_search',
type: 'POST',
//contentType: 'application/json; charset=UTF-8',
crossDomain: true,
dataType: 'json',
data: {
query:{match:{_all:$('#s_box').val()}},
pretty: true,
fields: '_id'
},
success: function(response) {
var data = response.hits.hits;
var doc_ids = [];
var source = null;
var content = '';
if (data.length > 0) {
for (var i = 0; i < data.length; i++) {
source = data[i].fields;
doc_ids.push(source._id);
content = content + ' ' + …Run Code Online (Sandbox Code Playgroud)