/**
   * Convert the query to Xml params that are compatible with the old KeywordSearch API
   *
   * @return parameters as Xml
   */
  public Element toXmlParams() {
    Element params = new Element("params");

    addXmlParam(params, XmlParams.offset, "" + offset);
    addXmlParam(params, XmlParams.maxResults, "" + maxResults);
    if (thesauriNames.isEmpty()) {
      if (thesauriDomainName != null) {
        addXmlParam(params, XmlParams.pType, thesauriDomainName);
      }
    } else {
      for (String name : thesauriNames) {
        addXmlParam(params, XmlParams.pThesauri, name);
      }
    }

    for (String lang : langs) {
      addXmlParam(params, XmlParams.pLang, lang);
    }

    for (SearchClause search : searchClauses) {
      search.addXmlParams(params);
    }

    return params;
  }
  private QueryBuilder<KeywordBean> createQuery() {
    Where where = Wheres.NONE;

    if (!searchClauses.isEmpty()) {
      for (SearchClause nextClause : searchClauses) {
        where = where.or(nextClause.toWhere(langs));
      }
    }

    QueryBuilder<KeywordBean> builder =
        QueryBuilder.keywordQueryBuilder(
                isoLangMapper, new ArrayList<String>(langs), requireBoundedBy)
            .offset(offset)
            .where(where);

    if (!selectClauses.isEmpty()) {
      for (Selector s : selectClauses) {
        builder.select(s, false);
      }
    }

    return builder;
  }