gpt4 book ai didi

html - 遍历Elasticsearch文档数组并打印它们

转载 作者:行者123 更新时间:2023-12-03 01:54:06 25 4
gpt4 key购买 nike

我有一个Elasticsearch查询结果

"tops":{

"hits":{

"total":21,"max_score":2.2237754,

"hits":[{"_index":"automatch_testing","_type":"temp_135","_id":"AVU7i0nnXK6g_oqHu-az","_score":2.2237754,"_source":{"t_pacs_id":"34","t_id":"60","matching":"MO"}},

{"_index":"automatch_testing","_type":"temp_143","_id":"AVU7iOSeXK6g_oqHu-XY","_score":2.2237754,"_source":{"t_pacs_id":"30","t_id":"60","matching":"MO","t_match":"matched"}},

{"_index":"automatch_testing","_type":"temp_135","_id":"AVU7i0nlXK6g_oqHu-ay","_score":2.2237754,"_source":{"t_pacs_id":"28","t_id":"60","matching":"MO","UICriteria":"135","t_match":"matched"}}]}}}



我想打印每个匹配项的来源...“匹配项”是 Controller 返回的结果。

我以这种方式尝试过...但是似乎没有用
 <div ng-repeat="hit in hits.tops.hits.hits">
<td > {{ rhit._source.t_pacs_id }}</td>
</div>

但是这段代码有效...打印了数组第一个元素的源
<p> {{ hits.tops.hits.hits[0]._source }} </p>

有没有办法遍历所有数组元素并打印它们?

最佳答案

您的第一次尝试已接近,我认为您有错别字。
检查此工作fiddle

<div ng-repeat="hit in data.tops.hits.hits">
<p > {{ hit._source.t_pacs_id }}</p>
</div>

我复制了您的数据并将其存储在 $scope.data中。

注意:不应在 <td>之外使用 <table>。考虑更改HTML。

关于html - 遍历Elasticsearch文档数组并打印它们,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37943206/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com