我试图建立动态的基础上一组字段的查询使用映射的集合。 这里的code。
I'm trying to build an aggregation dynamically based on a group of fields queried using the mapping. Here's the code.
$(document).ready(function(){
var query = {
aggs:{
sum_of_too_many_tries:{
sum:{
field:"reason.too_many_tries"
}
}
}
};
$.ajax({
url: "http://10.138.16.125:9200/log/blocks/_mapping",
type: "get",
async: false,
crossDomain: true,
success: function(data) {
var fields = Object.keys(data.log.mappings.blocks.properties.reasons.properties);
$.ajax({
url: "http://10.138.16.125:9200/log/blocks/_search",
crossDomain: true,
async: false,
type: "get",
dataType: "json",
data: JSON.stringify(query),
success: function(response) {
$("#dump").append(var_dump(response));
}
});
}
});
});
当我做了查询,它返回命中正常,无聚集。我究竟做错了什么?
When I do the query, it returns the hits normally, without the aggregations. What am I doing wrong?
如果你需要更多的code,只问。
If you need more code, just ask.
您需要发送的查询作为POST而不是GET。 当您发送它为GET,但是你打了_search API,不考虑查询的一部分。因此,你只会得到的前N个文件列的索引。
You need to sent your query as POST rather than GET. When you are sending it as GET , though you are hitting the _search API , the query part is not considered. Hence you will just get the top N documents out of the index.
上一篇:谷歌地图API第3版,使用AJAX通过setContent负载信息窗口的内容负载、窗口、地图、内容
下一篇:谷歌广场API - 否“访问控制 - 允许 - 原产地”标头的请求的资源present。原产地'空',因此没有允许访问原产地、访问控制、广场、资源