Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 974337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:25:17+00:00 2026-05-16T03:25:17+00:00

I have a program written in asp.net with lucene.net. At first I create an

  • 0

I have a program written in asp.net with lucene.net. At first I create an index from 28000 documents.
Secondly I’m executing a search, but sometimes there is an error. (I think this error is thrown when there are many results)

The important part of code:

Dim hits As Hits = searcher.Search(query)
Dim results As Integer = hits.Length()  'ergebnisse (größe der hits)

'#####################
'####### RESULTS #####
'#####################

trefferanzahl = results

If (results > 0) Then  
    Dim i As Integer
    Dim h As Integer = results - 1
    ReDim array_results(h, 6) 'array zum speichern von den "feldern"
    Dim cellX As New TableCell()

    For i = 0 To results - 1 Step 1 

        Dim tmpdoc As Document = hits.Doc(i)   ' HERE THE ERROR!
        Dim score As Double = hits.Score(i)     

        MsgBox("2. Docname: " & hits.Doc(i).Get("title"))


        array_results(i, 0) = tmpdoc.Get("title")
        array_results(i, 0) += tmpdoc.Get("doc_typ") 
        array_results(i, 1) = tmpdoc.Get("pfad")
        array_results(i, 2) = tmpdoc.Get("date_of_create")
        array_results(i, 3) = tmpdoc.Get("last_change")
        array_results(i, 4) = tmpdoc.Get("id")
        array_results(i, 5) = tmpdoc.Get("doc_typ")
        array_results(i, 6) = CStr(score)
    Next

    ' Load this data only once.

    ItemsGrid.DataSource = CreateDataSource()   
    ItemsGrid.DataBind()
Else
    bool_Suchergebnis = False
End If

searcher.Close()

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T03:25:17+00:00Added an answer on May 16, 2026 at 3:25 am

    A good principle when performing searches accross very large collections is to limit the results that you are processing as soon as possible. I will assume that you are implementing paging in your grid. And lets assume that PageSize is 20.

    What you need to do is make sure that you have access to the PageSize and the current PageNo within this method. Then use Linq accross the result set to Take(PageSize) and Skip (PageNo * PageSize). Then you will only have to process 20 records.

    Then, you have two options. If you are binding directly to the array, you might be able to get away with empty items, but I am not sure, so you might have to place dummy items into the datasource array in all positions that won’t be displayed. Not ideal, but certainly quicker than processing 1000s of Hits.

    The second option is to bind only the 20 items to the grid, which will be quick, switch off paging on the grid as it will only show one page and then implement your own paging behaviour as you know the PageSize, and the current PageNo. This will take more work but it will perform a lot faster than the out-of-the-box gridview binding to a large datasource.

    And it will help you solve your memory problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.