@Test public void testGetConceptsFromTermWithSpaces() { Query query = new Vocabulary.Query.Builder("hippocampus Formation").build(); assertThat(vocabulary.getConceptsFromTerm(query), contains(hippocampalFormation)); }
@Override public List<Concept> getConceptsFromTerm(Query query) { QueryParser parser = getQueryParser(); String exactQuery = String.format("\"\\^ %s $\"", query.getInput()); Builder finalQueryBuilder = new BooleanQuery.Builder(); try { if (query.isIncludeSynonyms() || query.isIncludeAbbreviations() || query.isIncludeAcronyms()) { Builder subQueryBuilder = new BooleanQuery.Builder(); subQueryBuilder.add(LuceneUtils.getBoostedQuery(parser, exactQuery, 10.0f), Occur.SHOULD); if (query.isIncludeSynonyms()) { subQueryBuilder.add(parser.parse(Concept.SYNONYM + ":" + exactQuery), Occur.SHOULD); } if (query.isIncludeAbbreviations()) { subQueryBuilder.add(parser.parse(Concept.ABREVIATION + ":" + exactQuery), Occur.SHOULD); } if (query.isIncludeAcronyms()) { subQueryBuilder.add(parser.parse(Concept.ACRONYM + ":" + exactQuery), Occur.SHOULD); } finalQueryBuilder.add(subQueryBuilder.build(), Occur.MUST); } else { finalQueryBuilder.add(parser.parse(exactQuery), Occur.MUST); } } catch (ParseException e) { logger.log(Level.WARNING, "Failed to parse query", e); } addCommonConstraints(finalQueryBuilder, query); BooleanQuery finalQuery = finalQueryBuilder.build(); logger.finest(finalQuery.toString()); try (Transaction tx = graph.beginTx()) { IndexHits<Node> hits = graph.index().getNodeAutoIndexer().getAutoIndex().query(finalQuery); tx.success(); return limitHits(hits, query); } }
VocabularyNeo4jImpl implements Vocabulary { @Override public List<Concept> getConceptsFromTerm(Query query) { QueryParser parser = getQueryParser(); String exactQuery = String.format("\"\\^ %s $\"", query.getInput()); Builder finalQueryBuilder = new BooleanQuery.Builder(); try { if (query.isIncludeSynonyms() || query.isIncludeAbbreviations() || query.isIncludeAcronyms()) { Builder subQueryBuilder = new BooleanQuery.Builder(); subQueryBuilder.add(LuceneUtils.getBoostedQuery(parser, exactQuery, 10.0f), Occur.SHOULD); if (query.isIncludeSynonyms()) { subQueryBuilder.add(parser.parse(Concept.SYNONYM + ":" + exactQuery), Occur.SHOULD); } if (query.isIncludeAbbreviations()) { subQueryBuilder.add(parser.parse(Concept.ABREVIATION + ":" + exactQuery), Occur.SHOULD); } if (query.isIncludeAcronyms()) { subQueryBuilder.add(parser.parse(Concept.ACRONYM + ":" + exactQuery), Occur.SHOULD); } finalQueryBuilder.add(subQueryBuilder.build(), Occur.MUST); } else { finalQueryBuilder.add(parser.parse(exactQuery), Occur.MUST); } } catch (ParseException e) { logger.log(Level.WARNING, "Failed to parse query", e); } addCommonConstraints(finalQueryBuilder, query); BooleanQuery finalQuery = finalQueryBuilder.build(); logger.finest(finalQuery.toString()); try (Transaction tx = graph.beginTx()) { IndexHits<Node> hits = graph.index().getNodeAutoIndexer().getAutoIndex().query(finalQuery); tx.success(); return limitHits(hits, query); } } }
VocabularyNeo4jImpl implements Vocabulary { @Override public List<Concept> getConceptsFromTerm(Query query) { QueryParser parser = getQueryParser(); String exactQuery = String.format("\"\\^ %s $\"", query.getInput()); Builder finalQueryBuilder = new BooleanQuery.Builder(); try { if (query.isIncludeSynonyms() || query.isIncludeAbbreviations() || query.isIncludeAcronyms()) { Builder subQueryBuilder = new BooleanQuery.Builder(); subQueryBuilder.add(LuceneUtils.getBoostedQuery(parser, exactQuery, 10.0f), Occur.SHOULD); if (query.isIncludeSynonyms()) { subQueryBuilder.add(parser.parse(Concept.SYNONYM + ":" + exactQuery), Occur.SHOULD); } if (query.isIncludeAbbreviations()) { subQueryBuilder.add(parser.parse(Concept.ABREVIATION + ":" + exactQuery), Occur.SHOULD); } if (query.isIncludeAcronyms()) { subQueryBuilder.add(parser.parse(Concept.ACRONYM + ":" + exactQuery), Occur.SHOULD); } finalQueryBuilder.add(subQueryBuilder.build(), Occur.MUST); } else { finalQueryBuilder.add(parser.parse(exactQuery), Occur.MUST); } } catch (ParseException e) { logger.log(Level.WARNING, "Failed to parse query", e); } addCommonConstraints(finalQueryBuilder, query); BooleanQuery finalQuery = finalQueryBuilder.build(); logger.finest(finalQuery.toString()); try (Transaction tx = graph.beginTx()) { IndexHits<Node> hits = graph.index().getNodeAutoIndexer().getAutoIndex().query(finalQuery); tx.success(); return limitHits(hits, query); } } @Inject  VocabularyNeo4jImpl(GraphDatabaseService graph,
      @Nullable @IndicatesNeo4jGraphLocation String neo4jLocation, CurieUtil curieUtil,
      NodeTransformer transformer); }
VocabularyNeo4jImpl implements Vocabulary { @Override public List<Concept> getConceptsFromTerm(Query query) { QueryParser parser = getQueryParser(); String exactQuery = String.format("\"\\^ %s $\"", query.getInput()); Builder finalQueryBuilder = new BooleanQuery.Builder(); try { if (query.isIncludeSynonyms() || query.isIncludeAbbreviations() || query.isIncludeAcronyms()) { Builder subQueryBuilder = new BooleanQuery.Builder(); subQueryBuilder.add(LuceneUtils.getBoostedQuery(parser, exactQuery, 10.0f), Occur.SHOULD); if (query.isIncludeSynonyms()) { subQueryBuilder.add(parser.parse(Concept.SYNONYM + ":" + exactQuery), Occur.SHOULD); } if (query.isIncludeAbbreviations()) { subQueryBuilder.add(parser.parse(Concept.ABREVIATION + ":" + exactQuery), Occur.SHOULD); } if (query.isIncludeAcronyms()) { subQueryBuilder.add(parser.parse(Concept.ACRONYM + ":" + exactQuery), Occur.SHOULD); } finalQueryBuilder.add(subQueryBuilder.build(), Occur.MUST); } else { finalQueryBuilder.add(parser.parse(exactQuery), Occur.MUST); } } catch (ParseException e) { logger.log(Level.WARNING, "Failed to parse query", e); } addCommonConstraints(finalQueryBuilder, query); BooleanQuery finalQuery = finalQueryBuilder.build(); logger.finest(finalQuery.toString()); try (Transaction tx = graph.beginTx()) { IndexHits<Node> hits = graph.index().getNodeAutoIndexer().getAutoIndex().query(finalQuery); tx.success(); return limitHits(hits, query); } } @Inject  VocabularyNeo4jImpl(GraphDatabaseService graph,
      @Nullable @IndicatesNeo4jGraphLocation String neo4jLocation, CurieUtil curieUtil,
      NodeTransformer transformer); @Override Optional<Concept> getConceptFromId(Query query); @Override List<Concept> getConceptsFromPrefix(Query query); @Override List<Concept> searchConcepts(Query query); @Override List<Concept> getConceptsFromTerm(Query query); @Override Set<String> getAllCategories(); @Override Set<String> getAllCuriePrefixes(); @Override List<String> getSuggestions(String query); }
VocabularyNeo4jImpl implements Vocabulary { @Override public List<Concept> getConceptsFromTerm(Query query) { QueryParser parser = getQueryParser(); String exactQuery = String.format("\"\\^ %s $\"", query.getInput()); Builder finalQueryBuilder = new BooleanQuery.Builder(); try { if (query.isIncludeSynonyms() || query.isIncludeAbbreviations() || query.isIncludeAcronyms()) { Builder subQueryBuilder = new BooleanQuery.Builder(); subQueryBuilder.add(LuceneUtils.getBoostedQuery(parser, exactQuery, 10.0f), Occur.SHOULD); if (query.isIncludeSynonyms()) { subQueryBuilder.add(parser.parse(Concept.SYNONYM + ":" + exactQuery), Occur.SHOULD); } if (query.isIncludeAbbreviations()) { subQueryBuilder.add(parser.parse(Concept.ABREVIATION + ":" + exactQuery), Occur.SHOULD); } if (query.isIncludeAcronyms()) { subQueryBuilder.add(parser.parse(Concept.ACRONYM + ":" + exactQuery), Occur.SHOULD); } finalQueryBuilder.add(subQueryBuilder.build(), Occur.MUST); } else { finalQueryBuilder.add(parser.parse(exactQuery), Occur.MUST); } } catch (ParseException e) { logger.log(Level.WARNING, "Failed to parse query", e); } addCommonConstraints(finalQueryBuilder, query); BooleanQuery finalQuery = finalQueryBuilder.build(); logger.finest(finalQuery.toString()); try (Transaction tx = graph.beginTx()) { IndexHits<Node> hits = graph.index().getNodeAutoIndexer().getAutoIndex().query(finalQuery); tx.success(); return limitHits(hits, query); } } @Inject  VocabularyNeo4jImpl(GraphDatabaseService graph,
      @Nullable @IndicatesNeo4jGraphLocation String neo4jLocation, CurieUtil curieUtil,
      NodeTransformer transformer); @Override Optional<Concept> getConceptFromId(Query query); @Override List<Concept> getConceptsFromPrefix(Query query); @Override List<Concept> searchConcepts(Query query); @Override List<Concept> getConceptsFromTerm(Query query); @Override Set<String> getAllCategories(); @Override Set<String> getAllCuriePrefixes(); @Override List<String> getSuggestions(String query);  }