code: private List populateUsingElasticSearch(Client client, EntityMetadata m)
      {
          Map<String, Object> searchFilter = client.getIndexManager().search(kunderaMetadata, kunderaQuery,
                  persistenceDelegeator, m, this.firstResult, this.maxResult);
          Object[] primaryKeys = ((Map<String, Object>) searchFilter.get(Constants.PRIMARY_KEYS)).values().toArray(
                  new Object[] {});
          Map<String, Object> aggregations = (Map<String, Object>) searchFilter.get(Constants.AGGREGATIONS);
  
          Iterable<Expression> resultOrderIterable = (Iterable<Expression>) searchFilter
                  .get(Constants.SELECT_EXPRESSION_ORDER);
          List<Object> results = new ArrayList<Object>();
  
          if (!kunderaQuery.isAggregated())
          {
              results.addAll(findUsingLucene(m, client, primaryKeys));
          }
          else
          {
              if (KunderaQueryUtils.hasGroupBy(kunderaQuery.getJpqlExpression()))
              {
                  populateGroupByResponse(aggregations, resultOrderIterable, results, client, m);
              }
              else
              {
                  Iterator<Expression> resultOrder = resultOrderIterable.iterator();
                  while (resultOrder.hasNext())
                  {
                      Expression expression = (Expression) resultOrder.next();
  
                      if (AggregateFunction.class.isAssignableFrom(expression.getClass()))
                      {
                          if (aggregations.get(expression.toParsedText()) != null)
                          {
                              results.add(aggregations.get(expression.toParsedText()));
                          }
                      }
                      else
                      {
                          results.addAll(findUsingLucene(m, client, new Object[] { primaryKeys[0] }));
                      }
                  }
              }
          }
  
          return results;
      }
docs: Populate using elastic search.
  
  @param client
  the client
  @param EntityMetadata
  the m
  @return Result list by fetching from ES