This is related to the a question I have asked previously. I have corrected my route according the answer give by @Val. With that I have an array containing arrays which has JSON objects. Ex:
[
[{_index:'myIndex',_type:'myType',_source:{name:'Name',age:25}},
{_index:'myIndex',_type:'myType',_source:{name:'Name',age:25}}
],
[{_index:'myIndex',_type:'myType',_source:{name:'Name',age:25}},
{_index:'myIndex',_type:'myType',_source:{name:'Name',age:25}}
]
]
So in my ejs file I am iterating through array as follows.
<% if(locals.players){ %>
<% for(var i=0;locals.players.length;i++){ %>
//some more code
<% var tp = locals.players[i]; %>
<% for(var j=0;tp.length;j++){ %>
<ul>
<li>
Name:<%= tp[j]._source.name %><br>
Age:<%= tp[j]._source.age %>
</li>
</ul>
<% } %>
<% } } %>
But I receive an error 'property _source undefined'. Just to add more details: the results array is coming from elasticsearch query. My intention is to print more results of another query which has objects from 1-D array. Second array contains arrays of results which correspond to each object in 1-D array.
localsvariable.<% if(locals.teams){%> <% for(var i=0;i<locals.teams.length;i++){ %> <ul><li> Name:<%= locals.teams[i]._source.name %> </li></ul> <%}}%>[{_index:myIndex,_type:myType,_source:{a:a, b:b}},{_index:myIndex,_type:myType,_source:{a:a, b:b}},{_index:myIndex,_type:myType,_source:{a:a, b:b}}]I can access to them<%= locals.teams[i]._source.a%>in a loop.var tp. Instead of that I changed the loop asfor(var j=0;j<locals.players[i][j].length;j++){..}. Now I don't have errors. But no display of players array data. Working on it now..