/** * Search by child id so return parent relationship. * * @param id * @param firstResult * @param maxResults * @return * @throws SolrServerException */ public QueryResponse searchByChildId(String id, Integer firstResult, Integer maxResults) throws SolrServerException { return searchById( id, firstResult, maxResults, OntologyFieldNames.CHILD_ID, childSearchesMap ); }
/** * Search by parent Id so returns children relationship. * * @param id * @param firstResult * @param maxResults * @return * @throws SolrServerException */ public QueryResponse searchByParentId(String id, Integer firstResult, Integer maxResults) throws SolrServerException { return searchById( id, firstResult, maxResults, OntologyFieldNames.PARENT_ID, parentSearchesMap ); }
private QueryResponse searchById( String id, Integer firstResult, Integer maxResults, final String fieldId, Map<String,QueryResponse> cache ) throws SolrServerException { // We need to include the maxResult in the key as we do different maxResult for // the same term, hence we could end up getting the wrong number of term. final String key = id + maxResults; if (cache.containsKey(key)) { return cache.get(key); } QueryResponse queryResponse = searchById( fieldId, id, firstResult, maxResults); cache.put(key, queryResponse); return queryResponse; }
private List<OntologyTerm> searchAndCacheById(String id, Integer firstResult, Integer maxResults, final String fieldId, Map<String, List<OntologyTerm>> cache) throws SolrServerException { // We need to include the maxResult in the key as we do different maxResult for // the same term, hence we could end up getting the wrong number of term. final String key = id + maxResults; if (cache.containsKey(key)) { return cache.get(key); } List<OntologyTerm> terms = searchById( fieldId, id, firstResult, maxResults); cache.put(key, terms); return terms; }