lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kunzman, Douglas *" <>
Subject Wildcard Terms and total word or phrase count
Date Fri, 27 Nov 2015 21:06:38 GMT
Hi -

This is my first Lucene project, my other search projects have used Solr.
I would like to find the total number of WildCard terms in a set of documents with 0-N matches
per document.
I would prefer not have to open each document where a match is found.  I need to be able to
support wildcards but my requirements are somewhat flexible in about phrase search support.
Whatever is easier.

This is what I have so far.

   public static void main(String args[]) throws IOException, ParseException {
        Directory idx =;

        Term term = new Term("Doc", "quar*");

        WildcardQuery wc = new WildcardQuery(term);

        SpanQuery spanTerm = new SpanMultiTermQueryWrapper<WildcardQuery>(wc);
        IndexReader indexReader =;

        System.out.println("Term freq=" + indexReader.totalTermFreq(term));
        System.out.println("Term freq=" + indexReader.getSumTotalTermFreq("Doc"));

        IndexSearcher isearcher = new IndexSearcher(indexReader);

        IndexReaderContext indexReaderContext = isearcher.getTopReaderContext();
        TermContext context =, term);
        TermStatistics termStatistics = isearcher.termStatistics(term, context);
        System.out.println("termStatics=" + termStatistics.totalTermFreq());

Does anyone have any suggestions?  totalTermFreq is zero, but when search using quartz we
find matches.
I'm searching the Quartz user's guide as an example.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message