Angularjs 执行elasticsearch的搜索查询时出错
我使用angularjs使用elasticsearch。我使用搜索查询来搜索elasticsearch中是否存在具有特定匹配项的文档,然后查询返回响应。我想从response中访问Angularjs 执行elasticsearch的搜索查询时出错,angularjs,Angularjs,我使用angularjs使用elasticsearch。我使用搜索查询来搜索elasticsearch中是否存在具有特定匹配项的文档,然后查询返回响应。我想从response中访问response.hits.max_score,但它会生成类型错误: 类型错误:无法获取未定义或null的属性“hits” 参考文献 将respounse.hits.max_score分配给.then body中可用函数中的$scope变量。解决方案显示在以下代码中: 搜索引擎({ 索引:“破折号”, 类型:'node
response.hits.max_score
,但它会生成类型错误:
类型错误:无法获取未定义或null的属性“hits”
参考文献
将respounse.hits.max_score分配给.then body中可用函数中的$scope变量。解决方案显示在以下代码中: 搜索引擎({ 索引:“破折号”, 类型:'node', 正文:{ “查询”: { “匹配”:{ “hostname”:name.hostname }
}, } }).然后(功能(响应){ $scope.result=response.hits.max_score;
}); 请将您的(stackoverflow.com/help/mcve)添加到问题中。
var serch = function() {
es.search({
index: 'index1',
type: 'type1',
body: {
"query": {
"match_all": {}
},
}
}).then(function(response) {});
$scope.result = response.hits.max_score;
}