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/04/30 16:10:54 UTC
DocsEnum <--- IndexReader.?
Hi,
I am trying to migrate some code from version 2.9.0 to 4.2.1, I have this method :
public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
OpenBitSet result = new OpenBitSet(reader.maxDoc());
TermDocs td = reader.termDocs(); <----- This line has error
try {
td.seek(term);
int[] arr = new int[BUFFER_SIZE];
int[] freq = new int[BUFFER_SIZE];
for (;;) {
int num = td.read(arr, freq);
if (num == 0)
break;
for (int j = 0; j < num; j++) {
result.fastSet(arr[j]);
}
}
} finally {
td.close();
}
return result;
}
The line that has error said :
The method termDocs() is undefined for the type IndexReader
I found this doc about migrating :
http://lucene.apache.org/core/4_0_0/MIGRATE.html
But IndexReader does not have a method that return the new class DocsEnum ( that renamed TermDocs).
Thanks, your help is appreciated.
Abdel
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
How to convert TermDocs and TermEnum ??
Posted by "A. Lotfi" <ma...@yahoo.com>.
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: DocsEnum <--- IndexReader.?
Posted by Michael McCandless <lu...@mikemccandless.com>.
Hmm MIGRATE is supposed to cover this ... try searching in
MIGRATE.html for "How you obtain the enums has changed"?
Mike McCandless
http://blog.mikemccandless.com
On Tue, Apr 30, 2013 at 10:10 AM, A. Lotfi <ma...@yahoo.com> wrote:
>
>
> Hi,
> I am trying to migrate some code from version 2.9.0 to 4.2.1, I have this method :
>
> public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
> OpenBitSet result = new OpenBitSet(reader.maxDoc());
> TermDocs td = reader.termDocs(); <----- This line has error
> try {
> td.seek(term);
> int[] arr = new int[BUFFER_SIZE];
> int[] freq = new int[BUFFER_SIZE];
> for (;;) {
> int num = td.read(arr, freq);
> if (num == 0)
> break;
> for (int j = 0; j < num; j++) {
> result.fastSet(arr[j]);
> }
> }
>
> } finally {
> td.close();
> }
> return result;
> }
>
> The line that has error said :
> The method termDocs() is undefined for the type IndexReader
>
> I found this doc about migrating :
> http://lucene.apache.org/core/4_0_0/MIGRATE.html
>
>
> But IndexReader does not have a method that return the new class DocsEnum ( that renamed TermDocs).
> Thanks, your help is appreciated.
>
> Abdel