public ComplexSolrConverter ( SolrServer solrServer ) { this ( new OntologySearcher ( solrServer ) ) ; }
private List<OntologyTerm> searchById(String fieldId, String id, Integer firstResult, Integer maxResults) throws SolrServerException { SolrQuery query = new SolrQuery(fieldId + ":\"" + id + "\""); if (firstResult != null) query.setStart(firstResult); if (maxResults != null) query.setRows(maxResults); if (FieldName.CHILDREN_ID.equalsIgnoreCase(fieldId)){ return processParentsHits(search(query, new String[] {OntologyFieldNames.PARENT_ID, OntologyFieldNames.PARENT_NAME, OntologyFieldNames.PARENT_SYNONYMS}), id); } else if (FieldName.PARENT_ID.equalsIgnoreCase(fieldId)) { return processChildrenHits(search(query, new String[] {OntologyFieldNames.CHILD_ID, OntologyFieldNames.CHILD_NAME, OntologyFieldNames.CHILDREN_SYNONYMS}), id); } else { return processParentsHits(search(query, new String[] {OntologyFieldNames.PARENT_ID, OntologyFieldNames.PARENT_NAME, OntologyFieldNames.PARENT_SYNONYMS}), id); } }
public List<OntologyTerm> getParents(boolean includeCyclic) { if (parents != null) { return parents; } try { this.parents = new ArrayList<OntologyTerm>(searcher.searchByChildId(id, 0, Integer.MAX_VALUE)); } catch (Exception e) { throw new IllegalStateException("Problem getting parents for document: " + id, e); } return parents; }
private OntologyNames searchOntologyNamesByName(String fieldId, String name, Integer firstResult, Integer maxResults) throws SolrServerException { SolrQuery query = new SolrQuery(fieldId + ":\"" + name + "\""); if (firstResult != null) query.setStart(firstResult); if (maxResults != null) query.setRows(maxResults); QueryResponse response = search(query, new String[] {OntologyFieldNames.CHILD_NAME, OntologyFieldNames.CHILDREN_SYNONYMS, OntologyFieldNames.CHILD_ID}); return extractNamesAndSynonymsFrom(response); }
/** * 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 ); }
private QueryResponse searchQuery(String idFieldName, boolean includeCyclic) throws SolrServerException { SolrQuery query = new SolrQuery(idFieldName+":\""+id+"\""); query.setRows(Integer.MAX_VALUE); // query.addFilterQuery("+"+OntologyFieldNames.CYCLIC+":"+String.valueOf(includeCyclic)); // query.addFilterQuery("+"+OntologyFieldNames.RELATIONSHIP_TYPE+":\"OBO_REL:is_a\""); // // if (!includeCyclic) { // query.addFilterQuery("-"+OntologyFieldNames.RELATIONSHIP_TYPE+":disjoint_from"); // } // query.setSortField(OntologyFieldNames.CHILD_NAME+"_s", SolrQuery.ORDER.asc); return searcher.search(query); }
public List<OntologyTerm> getChildren(boolean includeCyclic) { if (children != null) { return children; } try { this.children = new ArrayList<OntologyTerm>(searcher.searchByParentId(id, 0, Integer.MAX_VALUE)); } catch (Exception e) { throw new IllegalStateException("Problem getting children for document: "+id, e); } return children; }
@Override public void close() throws ItemStreamException { super.close(); if (this.ontologySearcher != null){ this.ontologySearcher.shutdown(); } }
@Override public boolean isExpandableOntology( final String name ) { if (expandableOntologies == null) { if (ontologySearcher == null) { expandableOntologies = new HashSet<String>(); } else { try { expandableOntologies = ontologySearcher.getOntologyNames(); } catch (SolrServerException e) { if (log.isErrorEnabled()) log.error("Problem getting list of ontology names: " +e.getMessage(), e); return false; } if (expandableOntologies.contains("uniprot taxonomy")) { expandableOntologies.add("taxid"); } } } return expandableOntologies.contains(name); }
private String findNameAndSynonyms(OntologySearcher searcher, String id, String defaultValue) throws SolrServerException { OntologyNames ontologyNames = searcher.findNameAndSynonyms(id, defaultValue); String childName = null; if (ontologyNames != null) { childName = ontologyNames.getName(); synonymsStr = ontologyNames.getSynonyms(); if (this.id == null){ this.id = ontologyNames.getId(); } } return childName == null ? defaultValue : childName; }
private OntologyNames searchOntologyNamesById(String fieldId, String id, Integer firstResult, Integer maxResults) throws SolrServerException { SolrQuery query = new SolrQuery(fieldId + ":\"" + id + "\""); if (firstResult != null) query.setStart(firstResult); if (maxResults != null) query.setRows(maxResults); QueryResponse response = search(query, new String[] {OntologyFieldNames.CHILD_NAME, OntologyFieldNames.CHILDREN_SYNONYMS, OntologyFieldNames.CHILD_ID}); return extractNamesAndSynonymsFrom(response); }
/** * 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 fieldId, String id, Integer firstResult, Integer maxResults) throws SolrServerException { SolrQuery query = new SolrQuery(fieldId + ":\"" + id + "\""); if (firstResult != null) query.setStart(firstResult); if (maxResults != null) query.setRows(maxResults); return search(query); } }
public List<OntologyTerm> getChildren(boolean includeCyclic) { if (children != null) { return children; } this.children = new ArrayList<OntologyTerm>(); try { final QueryResponse queryResponse = searcher.searchByParentId(id, 0, Integer.MAX_VALUE); children.addAll(processChildrenHits(queryResponse, id)); } catch (Exception e) { throw new IllegalStateException("Problem getting children for document: "+id, e); } return children; }
public void shutDown(){ this.ontologySearcher.shutdown(); this.interactionSearcher.shutdown(); }
@Override public boolean isExpandableOntology( final String name ) { if (expandableOntologies == null) { if (ontologySearcher == null) { expandableOntologies = new HashSet<String>(); } else { try { expandableOntologies = ontologySearcher.getOntologyNames(); } catch (SolrServerException e) { if (log.isErrorEnabled()) log.error("Problem getting list of ontology names: " +e.getMessage(), e); return false; } if (expandableOntologies.contains("uniprot taxonomy")) { expandableOntologies.add("taxid"); } } } return expandableOntologies.contains(name); }
public IntactSolrIndexer(SolrServer solrServer, HttpSolrServer ontologySolrServer) { this(solrServer); this.ontologySolrServer = ontologySolrServer; this.converter = new SolrDocumentConverter(solrServer, new OntologySearcher(ontologySolrServer)); }
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; }
public Set<String> getOntologyNames() throws SolrServerException { if (ontologyNames == null) { SolrQuery query = new SolrQuery("*:*"); query.setStart(0); query.setRows(0); query.setFacet(true); query.setParam(FacetParams.FACET_FIELD, "ontology"); QueryResponse response = search(query); FacetField facetField = response.getFacetField("ontology"); if (facetField.getValues() == null) { return Collections.EMPTY_SET; } ontologyNames = new HashSet<String>( facetField.getValues().size() ); for (FacetField.Count c : facetField.getValues()) { ontologyNames.add(c.getName()); } } return ontologyNames; }
public List<OntologyTerm> getParents(boolean includeCyclic) { if (parents != null) { return parents; } try { final QueryResponse queryResponse = searcher.searchByChildId(id, 0, Integer.MAX_VALUE); this.parents = new ArrayList<OntologyTerm>( queryResponse.getResults().size() ); parents.addAll(processParentsHits(queryResponse, id)); } catch (Exception e) { throw new IllegalStateException("Problem getting parents for document: " + id, e); } return parents; }