Click here to Skip to main content
Licence CPOL
First Posted 19 Oct 2008
Views 26,306
Downloads 2,052
Bookmarked 29 times

Lucene.net in asp.net simple example

By mascix | 19 Oct 2008 | Unedited contribution
How to use lucene.net api from c# in asp.net enviroment
1 vote, 14.3%
1

2
1 vote, 14.3%
3

4
5 votes, 71.4%
5
4.25/5 - 7 votes
μ 4.25, σa 2.93 [?]

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

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

Member
some of my projects:
sqlite asp.net profile membership role provider
play3w and for dom pro video player
english turkish dictionary

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 1 PinmemberAnoop19876:21 9 Aug '11  
Questionpassword ? Pinmemberhos cakal2:37 20 Jul '11  
AnswerRe: password ? Pinmembermascix5:28 20 Jul '11  
Generaldeneme.pfx PinmemberYanivush23:30 30 May '11  
GeneralAnother example of using Lucene.NET in ASP.NET Pinmemberctrager1:46 29 Mar '09  
GeneralNothing new PinmemberNeetflash4:19 23 Oct '08  
I don't have anything against your article. It's great, but it would have been nice to pick this subject, and show how can we use Lucene to index dynamic websites where the content is stored in a database or in alternative show how to use Lucene to crawl a website and index it's contents.

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

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120210.1 | Last Updated 19 Oct 2008
Article Copyright 2008 by mascix
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid