public void collectOntologyTermQueryMap(
      Map<String, String> expanedQueryMap, OntologyTerm ontologyTerm) {
    if (ontologyTerm != null) {
      getOtLabelAndSynonyms(ontologyTerm)
          .forEach(
              term -> expanedQueryMap.put(stemmer.cleanStemPhrase(term), ontologyTerm.getLabel()));

      for (OntologyTerm childOntologyTerm : ontologyService.getChildren(ontologyTerm)) {
        getOtLabelAndSynonyms(childOntologyTerm)
            .forEach(
                term ->
                    expanedQueryMap.put(stemmer.cleanStemPhrase(term), ontologyTerm.getLabel()));
      }
    }
  }
 /**
  * Create a boolean should query for composite tags containing multiple ontology terms
  *
  * @param multiOntologyTermIri
  * @return return a boolean should queryRule
  */
 public QueryRule createShouldQueryRule(String multiOntologyTermIri) {
   QueryRule shouldQueryRule = new QueryRule(new ArrayList<QueryRule>());
   shouldQueryRule.setOperator(Operator.SHOULD);
   for (String ontologyTermIri : multiOntologyTermIri.split(",")) {
     OntologyTerm ontologyTerm = ontologyService.getOntologyTerm(ontologyTermIri);
     List<String> queryTerms = parseOntologyTermQueries(ontologyTerm);
     Double termFrequency = termFrequencyService.getTermFrequency(ontologyTerm.getLabel());
     shouldQueryRule
         .getNestedRules()
         .add(createDisMaxQueryRuleForTermsWithBoost(queryTerms, termFrequency));
   }
   return shouldQueryRule;
 }
 /**
  * A helper function to collect synonyms as well as label of ontologyterm
  *
  * @param ontologyTerm
  * @return a list of synonyms plus label
  */
 public Set<String> getOtLabelAndSynonyms(OntologyTerm ontologyTerm) {
   Set<String> allTerms = Sets.newLinkedHashSet(ontologyTerm.getSynonyms());
   allTerms.add(ontologyTerm.getLabel());
   return allTerms;
 }