You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@lucene.apache.org by "A. Lotfi" <ma...@yahoo.com> on 2013/05/20 16:54:34 UTC

How to convert TermDocs and TermEnum ??

Hi,

I found some difficulties converting from old API to the newest one :

import org.apache.lucene.index.TermDocs;   // does not exist
import org.apache.lucene.index.TermEnum;  // does not exist

I tried the migration doc, but could not figure it out, here my code :

 private List<Short>[] loadFieldValues(IndexReader reader) throws IOException {
       
        List<Short>[] retArray = new List[reader.maxDoc()];
        TermEnum termEnum = reader.terms (new Term (GEO_LOC));
        try {
            do {
                Term term = termEnum.term();
                if (term==null || term.field() != GEO_LOC) break;
                TermDocs td = reader.termDocs(term);
                String value = term.text();
               .......
               ...........

                td.close();
            } while (termEnum.next());
            
        } finally {
            termEnum.close();
        }
        return retArray;
    }

I will appreciate your help.
thanks

Re: How to convert TermDocs and TermEnum ??

Posted by Michael McCandless <lu...@mikemccandless.com>.
Hi,

Have a look at MIGRATE.txt?

Mike McCandless

http://blog.mikemccandless.com


On Mon, May 20, 2013 at 10:54 AM, A. Lotfi <ma...@yahoo.com> wrote:
> Hi,
>
> I found some difficulties converting from old API to the newest one :
>
> import org.apache.lucene.index.TermDocs;   // does not exist
> import org.apache.lucene.index.TermEnum;  // does not exist
>
> I tried the migration doc, but could not figure it out, here my code :
>
>  private List<Short>[] loadFieldValues(IndexReader reader) throws IOException {
>
>         List<Short>[] retArray = new List[reader.maxDoc()];
>         TermEnum termEnum = reader.terms (new Term (GEO_LOC));
>         try {
>             do {
>                 Term term = termEnum.term();
>                 if (term==null || term.field() != GEO_LOC) break;
>                 TermDocs td = reader.termDocs(term);
>                 String value = term.text();
>                .......
>                ...........
>
>                 td.close();
>             } while (termEnum.next());
>
>         } finally {
>             termEnum.close();
>         }
>         return retArray;
>     }
>
> I will appreciate your help.
> thanks