protected Taxon[] findTaxon(String fieldName1, String fieldValue) throws IOException { Taxon[] terms = new TaxonImpl[0]; if (StringUtils.isNotBlank(fieldValue) && indexSearcher != null) { PhraseQuery query = new PhraseQuery(); query.add(new Term(fieldName1, fieldValue)); int maxHits = 3; TopDocs docs = indexSearcher.search(query, maxHits); if (docs.totalHits > 0) { terms = new TaxonImpl[docs.totalHits]; for (int i = 0; i < docs.totalHits && i < maxHits; i++) { ScoreDoc scoreDoc = docs.scoreDocs[i]; Document foundDoc = indexSearcher.doc(scoreDoc.doc); Taxon term = new TaxonImpl(); Fieldable idField = foundDoc.getFieldable(FIELD_ID); if (idField != null) { term.setExternalId(idField.stringValue()); } Fieldable rankPathField = foundDoc.getFieldable(FIELD_RANK_PATH); if (rankPathField != null) { term.setPath(rankPathField.stringValue()); } Fieldable rankPathIdsField = foundDoc.getFieldable(FIELD_RANK_PATH_IDS); if (rankPathIdsField != null) { term.setPathIds(rankPathIdsField.stringValue()); } Fieldable rankPathNamesField = foundDoc.getFieldable(FIELD_RANK_PATH_NAMES); if (rankPathNamesField != null) { term.setPathNames(rankPathNamesField.stringValue()); } Fieldable commonNamesFields = foundDoc.getFieldable(FIELD_COMMON_NAMES); if (commonNamesFields != null) { term.setCommonNames(commonNamesFields.stringValue()); } Fieldable fieldName = foundDoc.getFieldable(FIELD_RECOMMENDED_NAME); if (fieldName != null) { term.setName(fieldName.stringValue()); } terms[i] = term; } } } return terms; }