public List<SearchResult> search(final List<String> searchFields,
                                     final String searchTerm, final int count) throws Exception {
        val results = new ArrayList<SearchResult>();
        try (val directory = FSDirectory.open(indexDirectory.toPath());
             val reader = DirectoryReader.open(directory)) {
            val searcher = new IndexSearcher(reader);

            val booleanQuery = new BooleanQuery.Builder();
            for (val searchField : searchFields) {
                val query = new WildcardQuery(new Term(searchField, '*' + searchTerm.toLowerCase(Locale.ENGLISH) + '*'));
                booleanQuery.add(query, BooleanClause.Occur.SHOULD);

                val words = Splitter.on(' ').splitToList(searchTerm.toLowerCase(Locale.ENGLISH));
                val phraseQuery = new PhraseQuery.Builder();
                phraseQuery.setSlop(1);

                for (val word : words) {
                    phraseQuery.add(new Term(searchField, word));
                }
                booleanQuery.add(phraseQuery.build(), BooleanClause.Occur.SHOULD);

                val termQuery = new TermQuery(new Term(searchField, searchTerm.toLowerCase(Locale.ENGLISH)));
                booleanQuery.add(termQuery, BooleanClause.Occur.SHOULD);
            }
            val query = booleanQuery.build();
            val topDocs = searcher.search(query, count, Sort.RELEVANCE, true);

            for (val scoreDoc : topDocs.scoreDocs) {
                val doc = searcher.storedFields().document(scoreDoc.doc);
                val fields = doc.getFields().stream()
                    .map(field -> {
                        val highlight = field.stringValue().replace(searchTerm, "<i><b><u>" + searchTerm + "</i></b></u>");
                        return new ResultEntry(field.name(), highlight);
                    })
                    .toList();
                results.add(new SearchResult(fields));
            }
        }
        return results;
    }
Search data by entries.

@param searchFields the search entries
@param searchTerm   the query str
@return the list
@throws Exception the exception
support/cas-server-support-lucene/src/main/java/org/apereo/cas/lucene/LuceneSearchService.java