Click here to Skip to main content
15,867,686 members
Articles / Web Development / ASP.NET
Article

Lucene.net in asp.net simple example

Rate me:
Please Sign up or sign in to vote.
2.69/5 (11 votes)
19 Oct 2008CPOL1 min read 64.5K   5.1K   32   11
How to use lucene.net api from c# in asp.net enviroment

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)


Written By
Software Developer (Senior) http://www.mascix.com/
Turkey Turkey

Comments and Discussions

 
QuestionScriptresoursehandler error Pin
lolipopkitty9-May-15 22:45
lolipopkitty9-May-15 22:45 
General[My vote of 1] My Vote of 1 Pin
Alireza_13625-Dec-13 17:06
Alireza_13625-Dec-13 17:06 
GeneralMy vote of 1 Pin
Farshad khadempour10-Jan-13 6:00
professionalFarshad khadempour10-Jan-13 6:00 
GeneralMy vote of 1 Pin
Jeffrey Schaefer9-Aug-12 7:13
Jeffrey Schaefer9-Aug-12 7:13 
GeneralMy vote of 2 Pin
silvia.stanila17-Jul-12 19:44
silvia.stanila17-Jul-12 19:44 
GeneralMy vote of 1 Pin
Anoop19879-Aug-11 5:21
Anoop19879-Aug-11 5:21 
not working really sux
Questionpassword ? Pin
hos cakal20-Jul-11 1:37
hos cakal20-Jul-11 1:37 
AnswerRe: password ? Pin
ozkan.pakdil20-Jul-11 4:28
ozkan.pakdil20-Jul-11 4:28 
Generaldeneme.pfx Pin
Yanivush30-May-11 22:30
Yanivush30-May-11 22:30 
GeneralAnother example of using Lucene.NET in ASP.NET Pin
ctrager29-Mar-09 0:46
ctrager29-Mar-09 0:46 
GeneralNothing new Pin
Neetflash23-Oct-08 3:19
Neetflash23-Oct-08 3:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.