The Best C# Programmer In The World - Ben Perkins Member Login  | Newsletter | RSS Feeds


 
 
 
TheBestCSharpProgrammerInTheWorld.com 
 
The Best C# Programmer In The World - Ben Perkins
How to create and search a Lucene.Net index in 4 simple steps using C#, Step 4  
 
How to create and search a Lucene.Net index in 4 simple steps using C#, Step 4
 
Please rate:
 
Display the results.
 
To view the results we need to loop through the ScoreDoc array we created in Part3. We do this by iterating through it within a for loop.
 
 
                        
                        for (int i = 0; i < hits.Length; i++)
                        {
                          int docId = hits[i].doc;
                          float score = hits[i].score;
                                            
                          Lucene.Net.Documents.Document doc = searcher.Doc(docId);
                                                                
                         string result = "Score: " + score.ToString() + 
                                         " Field: " + doc.Get("fieldName") + 
                                         " Field2: " + doc.Get("TERM");
                        }
                        
                         
 
That’s it. Follow these steps and you will have implemented a very powerful search capability.
 
 
 
 
 
 
 
Feedback / Question
 
Your Name:Your Email:
 
Subject:
 
Feedback/Question:
 
 
 
I had to remove the capability to leave feedback due to this. Will be back soon.
 
 
Comment posted: 5/11/2011 11:54:48 AM by Johnie
 
Cool! That's a clever way of looknig at it!
Comment posted: 3/28/2011 9:55:29 AM by Ben Perkins
 
Hi, you should be able to create a lucene.net index based on database data using the code in step 1. Instead of looping through a directory of files, loop through a resultset retrieved from the database. Use the doc.Add for the data you want to search. Good luck!
Comment posted: 5/10/2011 6:54:01 AM by Kyanna
 
Very true! Makes a cnaghe to see someone spell it out like that. :)
Comment posted: 1/17/2012 6:30:13 PM by seo marketing
 
You will have to consider aspect inside an important challenge for one from all of the most beneficial blog sites for all of the net. I actually can suggest www.thebestcsharpprogrammerintheworld.com !
Comment posted: 5/11/2011 11:30:25 AM by Lottie
 
That's 2 clever by half and 2x2 clever 4 me. Tahkns!
Comment posted: 5/10/2011 7:37:16 PM by Stafon
 
I feel so much happier now I unedrsatnd all this. Thanks!
Comment posted: 3/27/2011 11:33:12 PM by Hai Dong
 
Can you share me a source code ?, i have a ms sql database , and i want to you lucene.net search on my database . thank you a lot , wish u all best wish
 
page.Translate()
 
 
blog.Stats()
 
  Posts: 113
  Comments: 86
  Fundamentals: 16
 
my.Book()

 
me.About()
 
 
 
 
 
blog.Archive()
 
2012 May  (4)
2012 April  (5)
2012 March  (4)
2012 February  (4)
2012 January  (5)
2011 December (2)
2011 November (6)
2011 October (7)
2011 September (7)
2011 August (9)
2011 July (9)
2011 June (8)
2011 May (9)
2011 April (7)
2011 March (9)
2011 February (8)
2011 January (8)
2010 December (7)
2010 November (8)
2010 October (4)
 
site.Visits()
 
free counters
 
tag.Cloud()
 
code.Disclaimer()
 
The sample code on this website is provided to illustrate a concept and should not be used in applications or Web sites without proper professional consultation, as it may not illustrate the safest coding practices. I assume no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.
 
   


The Best C# Programmer In The World - Ben Perkins, © 2010, All Rights ReservedContact Ben