private List<Field> convertTermsToFieldsIncludingSynonyms(String type, Set<OntologyTerm> terms) { List<Field> fields = new ArrayList<Field>(); if (terms != null) { for ( OntologyTerm term : terms ) { if (!getOntologyTermsToIgnore().contains(term.getId())){ Collection<Field> fieldsWithSynonyms = convertTermToFieldIncludingSynonyms(type, term); fields.addAll( fieldsWithSynonyms ); } } } return fields; }
private Field convertTermToField(String type, OntologyTerm term) { return new Field( type, term.getId(), term.getName() ); }
private Field convertTermToField(String type, OntologyTerm term) { Field field = new DefaultField( ); field.set(CalimochoKeys.DB, type); field.set(CalimochoKeys.VALUE, term.getId()); field.set(CalimochoKeys.TEXT, term.getName()); return field; }
public void enrichOrganism(Interaction interaction, SolrInputDocument solrDocument) throws SolrServerException { // retrieve the ontology term for this interaction (using BioSource) final OntologyTerm ontologyTerm = findOrganism(interaction) ; // add name, all synonyms and tax id to complex_organism if ( ontologyTerm != null ) { // enrich exact organism enrichOrganism(ComplexFieldNames.COMPLEX_ORGANISM_EXACT, null, solrDocument, ontologyTerm); // enrich organism for query enrichOrganism(ComplexFieldNames.COMPLEX_ORGANISM, ComplexFieldNames.COMPLEX_ORGANISM_F, solrDocument, ontologyTerm); // sort field solrDocument.addField(ComplexFieldNames.COMPLEX_ORGANISM_SORT, ontologyTerm.getId()); // stored field to retrieve from the index solrDocument.addField(ComplexFieldNames.ORGANISM_NAME, ontologyTerm.getName()+"; "+ontologyTerm.getId()); // add parents to complex_organism_ontology for ( OntologyTerm parent : ontologyTerm.getAllParentsToRoot ( true ) ) { enrichOrganism(ComplexFieldNames.COMPLEX_ORGANISM, null, solrDocument, parent); } } }
protected void enrichOrganism(String fieldName, String facetField, SolrInputDocument solrDocument, OntologyTerm ontologyTerm) { // name solrDocument.addField ( fieldName, ontologyTerm.getName( ) ) ; // synonyms for ( OntologyTerm synonym : ontologyTerm.getSynonyms ( ) ) { solrDocument.addField ( fieldName, synonym.getName() ) ; } // taxid solrDocument.addField ( fieldName, ontologyTerm.getId() ) ; // facet field if (facetField != null){ solrDocument.addField(facetField, ontologyTerm.getName()); } }
solrDocument.addField ( xrefFieldName, parent.getId() ) ; solrDocument.addField ( xrefFieldName, parent.getName ( ) ) ; for ( OntologyTerm synonym : parent.getSynonyms ( ) ) {