/** * Builds a query with the provided input terms over the given fields * * @param fields * @param input * @return the query * @throws InvalidQueryException */ public static String buildLuceneQuery(List<String> fields, String input) throws InvalidQueryException { StringBuilder result = new StringBuilder(); input = replaceNonAlphaNummeric(input); List<String> terms = split(input); if (fields!=null && !fields.isEmpty()) { terms = attachFields(fields, terms); } terms = assembleAndClauses(terms); for (String term : terms) { if (result.length() > 0) result.append(" "); result.append(term); } return result.toString().trim(); }