Validate Hibernate Search Input with an Analyzer

Stop Words


[“a”, “an”, “and”, “are”, “as”, “at”, “be”, “but”, “by”, “for”, “if”,
 “in”, “into”, “is”, “it”, “no”, “not”, “of”, “on”, “or”, “such”, “that”,
 “the”, “their”, “then”, “there”, “these”, “they”, “this”, “to”, “was”, “will”, “with”]


List<String> keywordsList = Arrays.asList(searchKeywords.split(" "));


The query string 'of' applied on field 'title' has no meaningfull tokens to be matched. Validate the query input against the Analyzer applied on this field.


Validate.notNull(entityManager, "Entity manager can't be null");
FullTextEntityManager fullTextEntityManager =
QueryBuilder builder = fullTextEntityManager.getSearchFactory()


     * Validate input against the tokenizer and return a list of terms.
     * @param analyzer
     * @param string
     * @return
    public static List<String> tokenizeString(Analyzer analyzer, String string)
            TokenStream stream = analyzer.tokenStream(null, new StringReader(string));
            while (stream.incrementToken())
        } catch (IOException e)
            // not thrown b/c we're using a string reader...
            throw new RuntimeException(e);
        return result;


Leave a Reply

