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 6000643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:43:23+00:00 2026-05-23T00:43:23+00:00

I am doing a search operation by using lucene where i was taking my

  • 0

I am doing a search operation by using lucene where i was taking my results by using topscorecollector, but i found that it unable to sort my topscorecollector results. I found it quiet odd to sort that. Can we sort the TopscoreCollector results?

My code looks like this

        TopScoreDocCollector collector = TopScoreDocCollector.create(100, true);
        indexSearch.Search(andSearchQuery, filter, collector);
        ScoreDoc[] hits = collector.TopDocs().scoreDocs;
        for (int i = 0; i < hits.Length; i++)
        {
            int docId = hits[i].doc;
            float score = hits[i].score;
            Lucene.Net.Documents.Document doc = indexSearch.Doc(docId);
            document.Add(doc);
        }

Can anybody help me?

Also one more doubt
we can sort the search results like this

Hits hits = IndexSearch.search(searchQuery, filter, sort);

But it is showing that Hits become obselete by Lucene 3.0. so i have opted for TopscoreCollector. But now iam very much confused?

If anyother alternate method for Hits, Please pass that to me…

  • 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-23T00:43:24+00:00Added an answer on May 23, 2026 at 12:43 am

    TopScoreDocCollector will return results sorted by score. To get results sorted on a field you will need to use a method overload that returns TopFieldDocs.

    IE: IndexSearcher.Search(query, filter, nResults, sort)

    If you dont want to limit the number of results use a very large value for the nResults parameter. If i remember correctly passing Int32.MAX_VALUE will make Lucene generate an exception when initializing its PriorityQueue but Int32.MAX_VALUE-1 is fine.

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

Sidebar

Related Questions

I am doing this search engine that should only search my content, but in
I am doing a ALPHABETICAL ORDER SEARCH module for a project. that is it
How do I search and replace whole words using sed? Doing sed -i 's/[oldtext]/[newtext]/g'
I want to parse a search string similar to that provided by Gmail using
I am using Handler to make the UI responsive when doing search. I used
I'm currently working on some search and replace operation that I'm trying to automate
Im doing a search where the POST is: sok3 = 0,2,6 I would then
After doing a long search on stackoverflow i didn't find any one talked about
After doing a light search on the Lazarus site I've come to the conclusion
The Mongoid documentation only gives one example of doing a wildcard search: Person.where(first_name: /^d/i)

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.