lucenenet-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Honeycutt <mbhoneyc...@gmail.com>
Subject Re: Alternative to looping through Hits
Date Fri, 02 Oct 2009 15:09:44 GMT
With ~6,000 appends, I would expect StringBuilder to be
*significantly*faster.  Most benchmarks I've seen show that it is
faster to use a
SringBuilder than string concatenation once you pass ~30 appends...  if it
was slower, maybe something else is going on?

On Fri, Oct 2, 2009 at 10:02 AM, Trevor Watson <twatson@datassimilate.com>wrote:

> I had done StringBuilder.Append for the HitsIterator.  It actually
> increased the time by about 5 seconds.  It might be just computer issue at
> that time, however, it didn't seem to be beneficial time-wise.
>
>
>
>
> Gerald Pape wrote:
>
>> Hi,
>> would start with using StringBuilder instead of string, maybe this gives
>> some performance boost.
>>
>>
>>
>>
>>
>> From:   Trevor Watson <twatson@datassimilate.com>
>> To:     lucene-net-user@incubator.apache.org
>> Date:   02.10.2009 16:42
>> Subject:        Alternative to looping through Hits
>>
>>
>>
>> I am currently attempting to create a comma separated list of IDs from a
>> given Hits collection.
>>
>> However, when we end up processing 6,000 or more hits, it takes 25-30
>> seconds per collection.  I've been trying to find a faster way to change the
>> search results to the comma separated list.  Do any of you have any advice?
>>  Thanks in advance.
>>
>> Trevor Watson
>>
>>
>> My current code looks like
>>
>> Lucene.Net.Search.Searcher search = new
>> Lucene.Net.Search.IndexSearcher(string.Format("c:\\sv_index\\" +
>> jobId.ToString()));
>>            Lucene.Net.Search.Hits hits = search.Search(query);
>>
>>            string docIds = "";
>>            totalDocuments = hits.Length();
>>
>>            // Test #1
>>            Lucene.Net.Search.HitIterator hi =
>> (Lucene.Net.Search.HitIterator)hits.Iterator();
>>            while (hi.MoveNext())
>>                docIds +=
>> ((Lucene.Net.Search.Hit)hi.Current).GetDocument().GetField("DocumentId").StringValue()
>>
>> + ", ";
>>
>>          // Test #2
>>            for (int iCount = 0; iCount < totalDocuments; iCount++)
>>            {
>>                Lucene.Net.Documents.Document docHit = hits.Doc(iCount);
>>
>>                docIds += docHit.GetField("DocumentId").StringValue() + ",
>> ";
>>            }
>>
>>
>>
>>
>>
>>
>>
>>
>
>

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