lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Digy" <>
Subject RE: New to Apache Lucene.Net 2.0.0
Date Tue, 06 Mar 2007 18:08:40 GMT
Hi Tony
No diff. whether coding in WinForms or ASP.NET
I prepared a simple example for you.

private void Form1_Load(object sender, EventArgs e)
            string IndexPath=@"c:\temp\blabla";
            bool createANewIndex = true; //true:"New index" false:"use
existing index"

            IndexWriter wr = new IndexWriter(IndexPath, new
Lucene.Net.Analysis.Standard.StandardAnalyzer(), createANewIndex);
            IndexDocument(wr, @"c:\temp\somedoc1.txt");
            IndexDocument(wr, @"c:\temp\somedoc2.txt");

            Search(IndexPath, "hakuna matata");

        void IndexDocument(IndexWriter wr,string DocumentPathToIndex)
            StreamReader rd = new StreamReader(DocumentPathToIndex);

            Document doc = new Document();
            Field f1 = new Field("FileName", DocumentPathToIndex,
Field.Store.YES, Field.Index.NO);
            Field f2 = new Field("Text", rd.ReadToEnd(), Field.Store.NO,


        private void Search(string Path,string TextToSearch)
            IndexSearcher searcher     = new IndexSearcher(Path);

            QueryParser queryParser = new QueryParser("Text", new
            Query query = queryParser.Parse(TextToSearch);
            Hits hits = searcher.Search(query);

            string s = "";
            for (int i = 0; i < hits.Length(); i++)
                s += hits.Doc(i).GetField("FileName").StringValue() + "\n";



-----Original Message-----
From: tony njedeh [] 
Sent: Monday, March 05, 2007 10:11 PM
Subject: New to Apache Lucene.Net 2.0.0

    Good Morning guys, 
  I hope you all had a good weekend. 
  I wanted to ask if anyone had a simple example of indexing and searching
   I went through the code I downloaded from the site and the code for
indexing and searching kept getting me confused.
  Thanks all, and please forgive my naive questions.

Ed Jones wrote:

Try downloading the files from simply
download the ZIP file and look for the dll I the bin directory. Add as a
reference in your project.

Then take a look at the 5 tutorials here , they are in c# but you can use an
online converter like this one:

I had the same learning curve as you and although I only dabbled with
Lucene I got an indexer and searching system working quite quickly.

Hope that helps

-----Original Message-----
From: tony njedeh [] 
Sent: 02 March 2007 20:05
Subject: RE: New to Apache Lucene.Net 2.0.0

Regarding the, am I to compile my files and get the .dll
files or its provided on the website.

And the first step, I would like to make is, indexing and building a
test document I can search with.

I am sorry for my elementary questions, I am very new to the lucene

Thank you


Max Metral wrote:
Sorry, my respose was leading but not informative. I would think you'd
be better off including the .Net dll and leaving it in its original
state. You should not need Java at all, unless you want to use the
Lucene Index Explorer for debugging (which is nice). What is the next
step you're trying to do? Index something? Build a test document?

-----Original Message-----
From: tony njedeh [] 
Sent: Friday, March 02, 2007 2:24 PM
Subject: RE: New to Apache Lucene.Net 2.0.0

The website I work on, is set up in VB and not C#

Max Metral wrote: Why did you convert them?

-----Original Message-----
From: tony njedeh [] 
Sent: Friday, March 02, 2007 2:10 PM
Subject: New to Apache Lucene.Net 2.0.0

Hi everyone,

I am new to lucene and I wanted to use the search engine in my application). I have converted the C# files I downloaded from
the in the url to VB
files. I also downloaded Java 5.

I was hoping, if you guys could guide me through the next steps to
make, because I am seriously out of my element here.

Thank you

View raw message