Click here to Skip to main content
6,595,444 members and growing! (16,175 online)
Email Password   helpLost your password?
Web Development » ASP.NET » Samples     Beginner License: The Code Project Open License (CPOL)

Lucene.net in asp.net simple example

By mascix

How to use lucene.net api from c# in asp.net enviroment
C#, ASP.NET, Dev
Posted:19 Oct 2008
Views:8,649
Bookmarked:11 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
4 votes for this article.
Popularity: 2.77 Rating: 4.60 out of 5

1

2
1 vote, 25.0%
3

4
3 votes, 75.0%
5

Introduction 

Lucene.Net is a source code, class-per-class, API-per-API and algorithmatic port of the Java Lucene search engine to the C# and .NET platform utilizing Microsoft .NET Framework. And this is a very simple asp.net example to show how you can call Lucene API. This example creates lucene index and makes a search on it. 

Background

It would be nice if you already used lucene before but there is no need to dig into that java world. this example stands for that.

Using the code

When you start using lucene you need to check is the Index exist or not this function will help you to cover that area. 

private void IsIndexExists(out bool created, string sIndexPath)
{
    created = false;
    if (!IndexReader.IndexExists(sIndexPath))
    {
        IndexWriter writer = new IndexWriter(sIndexPath,
            new StandardAnalyzer(), true);
        created = true;
        writer.Close();
    }
}
		

this is not a full of code example. this is the simplest way to use pure lucene.net API from asp.net that is why you should download the code and check it out.

Points of Interest

I had a problem with godaddy shared hosting when I tried to use lucene.net there. btw I have deluxe windows hosting. And changed somelines from lucene.net svn(Revision 706104) code and decided to publish it here. The lucene.net dll which comes from this example's zip file is tested here.

History

20/10/2008   for the turkish version of this article blog.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

mascix


Member
some of my projects:
sqlite asp.net profile membership role provider
play3w and for dom pro video player
english turkish dictionary
Occupation: Software Developer (Senior)
Company: http://www.dol.com.tr/
Location: Turkey Turkey

Other popular ASP.NET articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 2 of 2 (Total in Forum: 2) (Refresh)FirstPrevNext
GeneralAnother example of using Lucene.NET in ASP.NET Pinmemberctrager1:46 29 Mar '09  
GeneralNothing new PinmemberNeetflash4:19 23 Oct '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 19 Oct 2008
Editor:
Copyright 2008 by mascix
Everything else Copyright © CodeProject, 1999-2009
Web19 | Advertise on the Code Project