0

i have a elasticsearch query result as

"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"}}]}}}

i want to print the source of each hit..."hits" is the result returned by the controller.

i tried it this way...but didn't seem to work

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

but this code worked...which prints the source of the first element of the array

<p> {{ hits.tops.hits.hits[0]._source }} </p>

is there any way of iterating through all the array elements and printing them??

2 Answers 2

1

Your first attempt is close, you have a typo i think. Check this working fiddle

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

I copied your data and stored it in $scope.data.

Note: You should not use a <td> outside a <table>. Consider changing your HTML.

Sign up to request clarification or add additional context in comments.

Comments

0

It should work, here's an example Plnkr:

  <body ng-controller="MainCtrl">
    <div ng-repeat="hit in hits.tops.hits.hits">{{hit._source.t_pacs_id}}</div>
  </body>

Problem is probably that you are trying to display the data in td elements. td needs to be within a table and a table row.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.