private FulltextSearchHit[] constructFulltextSearchList(JSONObject solrResultsJSON,FulltextSearchQuery query) throws JSONException {
  String searchColumn=query.getSearchField();
  String snippetColumn=query.getSnippetField();
  String scoreColumn=query.getScoreField();
  JSONObject resp=solrResultsJSON.getJSONObject("response");
  JSONArray docs=resp.getJSONArray("docs");
  List<FulltextSearchHit> searchHits=new ArrayList<FulltextSearchHit>(docs.length());
  for (int i=0; i < docs.length(); i++) {
    JSONObject result=docs.getJSONObject(i);
    String search=null;
    if (searchColumn != null && !searchColumn.isEmpty() && result.has(searchColumn)) {
      search=flattenJsonResult(result.get(searchColumn));
    }
 else {
      throw new FulltextSearchException("Search field undefined, empty, or does not exist.");
    }
    String snippet=null;
    if (snippetColumn != null && !snippetColumn.isEmpty()) {
      snippet=result.has(snippetColumn) ? flattenJsonResult(result.get(snippetColumn)) : null;
    }
    String score=null;
    if (scoreColumn != null && !scoreColumn.isEmpty()) {
      score=result.has(scoreColumn) ? flattenJsonResult(result.get(scoreColumn)) : null;
    }
    Double scoreAsDouble=null;
    if (score != null) {
      try {
        scoreAsDouble=Double.valueOf(score);
      }
 catch (      NumberFormatException e) {
        if (log.isInfoEnabled()) {
          log.info("Could not cast score to double: " + score);
        }
      }
    }
    if (search != null && !search.isEmpty()) {
      FulltextSearchHit currentHit=new FulltextSearchHit(search,scoreAsDouble,snippet,query.getIncomingBindings(),query.getSearchResultType());
      searchHits.add(currentHit);
    }
  }
  return searchHits.toArray(new FulltextSearchHit[searchHits.size()]);
}

private FulltextSearchHit [ ] constructFulltextSearchList ( JSONObject solrResultsJSON , FulltextSearchQuery query ) throws JSONException { String searchColumn = query . getSearchField ( ) ; String snippetColumn = query . getSnippetField ( ) ; String scoreColumn = query . getScoreField ( ) ; JSONObject resp = solrResultsJSON . getJSONObject ( "response" ) ; JSONArray docs = resp . getJSONArray ( "docs" ) ; List < FulltextSearchHit > searchHits = new ArrayList < FulltextSearchHit > ( docs . length ( ) ) ; for ( int i = 0 ; i < docs . length ( ) ; i ++ ) { JSONObject result = docs . getJSONObject ( i ) ; String search = null ; if ( searchColumn != null && ! searchColumn . isEmpty ( ) && result . has ( searchColumn ) ) { search = flattenJsonResult ( result . get ( searchColumn ) ) ; } else { throw new FulltextSearchException ( "Search field undefined, empty, or does not exist." ) ; } String snippet = null ; if ( snippetColumn != null && ! snippetColumn . isEmpty ( ) ) { snippet = result . has ( snippetColumn ) ? flattenJsonResult ( result . get ( snippetColumn ) ) : null ; } String score = null ; if ( scoreColumn != null && ! scoreColumn . isEmpty ( ) ) { score = result . has ( scoreColumn ) ? flattenJsonResult ( result . get ( scoreColumn ) ) : null ; } Double scoreAsDouble = null ; if ( score != null ) { try { scoreAsDouble = Double . valueOf ( score ) ; } catch ( NumberFormatException e ) { if ( log . isInfoEnabled ( ) ) { log . info ( "Could not cast score to double: " + score ) ; } } } if ( search != null && ! search . isEmpty ( ) ) { FulltextSearchHit currentHit = new FulltextSearchHit ( search , scoreAsDouble , snippet , query . getIncomingBindings ( ) , query . getSearchResultType ( ) ) ; searchHits . add ( currentHit ) ; } } return searchHits . toArray ( new FulltextSearchHit [ searchHits . size ( ) ] ) ; }
constructs a list of fulltext search results from a solr json result string .
