lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Barry Coughlan <b.coughl...@gmail.com>
Subject Re: Retrieve found terms
Date Wed, 26 Nov 2014 13:28:01 GMT
You can enumerate the terms by wrapping the TermsEnum in a PrefixTermsEnum,
e.g.

    Terms terms = fields.terms(field);
    TermsEnum termsEnum = new PrefixTermsEnum(terms.iterator(null),
new BytesRef("arch*"));
    BytesRef text;
    while((text = termsEnum.next()) != null) {
      System.out.println("field=" + field + "; text=" + text.utf8ToString());
    }


On Tue, Nov 25, 2014 at 2:12 PM, John Cecere <john.cecere@oracle.com> wrote:

> I've done a bunch of searching, but I still can't seem to figure out how
> to do this.
>
> Given a WildcardQuery or PrefixQuery (something with a wildcard in it), is
> there a way to retrieve the terms in the index that matched in a document?
> For example, the search term for my WildcardQuery is 'arch*' and I got 3
> hits on it. I want to know what terms in the indexed matched (e.g. archery,
> architecture, archenemy).
>
> More specifically, I'd like to do this without having to use the
> highlighter jar.
>
> I already have my index set up with term vectors enabled.
>
> Thanks,
> John
>
> --
> John Cecere
> Principal Engineer - Oracle Corporation
> 732-987-4317 / john.cecere@oracle.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

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