[Fwd: TermEnum usage]

2010-07-22 Thread Vincent DARON
Without any answers, I'm reposting once. Do I have to post bug report ?

Let me know

Thanks a lot

Vincent DARON
ASK
--- Begin Message ---
Hi all

I'm using Lucene.NET 2.9.2.2 from SVN.

I try to iterate terms of a field in my index, todo so, i'm using
IndexReader.Terms(f) that return a TermEnum.

The classic usage of iterator is the folowing pattern

TermNum enu = reader.Terms(new Term("myfield"));
while(enu.Next())
{
ProcessTerm(enu.Term());
}

But it seems that the TermEnum is already on the first item BEFORE the
first call to Next. The previous code will therefore always skip the
first Term.

Bug ?

Thanks

Vincent DARON
ASK
--- End Message ---


Re: [Fwd: TermEnum usage]

2010-07-22 Thread Ben West
Hey Vincent,

I am not a dev, but for example look at FuzzyQuery.cs (starting at line 148):

do 
{
  float score = 0.0f;
  Term t = enumerator.Term();
  if (t != null) 
  {
// some stuff with t
  }
}
while (enumerator.Next());

you can see that it is expecting the enumerator to have a term in it before it 
calls next [i.e. it is using do...while rather than just while]. So I think 
this is expected behavior, although it may not be intuitive.

Hope this helps,
-Ben

--- On Thu, 7/22/10, Vincent DARON  wrote:

> From: Vincent DARON 
> Subject: [Fwd: TermEnum usage]
> To: "lucene-net-dev" 
> Date: Thursday, July 22, 2010, 10:10 AM
> Without any answers, I'm reposting
> once. Do I have to post bug report ?
> 
> Let me know
> 
> Thanks a lot
> 
> Vincent DARON
> ASK
> 


  


RE: [Fwd: TermEnum usage]

2010-07-22 Thread Vincent DARON
Strange, but OK

Thanks a lot for answers

Vincent

Le jeudi 22 juillet 2010 à 19:54 +0300, Digy a écrit : 
> It is expected behavior. Please see 
> 
> http://lucene.apache.org/java/2_9_2/api/all/org/apache/lucene/index/IndexReader.html#terms%28org.apache.lucene.index.Term%29
> 
> DIGY
> 
> -Original Message-
> From: Vincent DARON [mailto:vda...@ask.be] 
> Sent: Thursday, July 22, 2010 6:10 PM
> To: lucene-net-dev
> Subject: [Fwd: TermEnum usage]
> 
> Without any answers, I'm reposting once. Do I have to post bug report ?
> 
> Let me know
> 
> Thanks a lot
> 
> Vincent DARON
> ASK
>