ok, i have searched for this in the past two hours with results that only give's tips, and not even one complete code to the rescue ( how would noobs learn if they cant see some samples ? )
i have created an index like so:
Directory directory = FSDirectory.Open(new System.IO.DirectoryInfo(Server.MapPath("/data/channels/")));
Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_29);
IndexWriter writer = new IndexWriter(directory, analyzer, true, Lucene.Net.Index.IndexWriter.MaxFieldLength.UNLIMITED);
Document doc = new Document();
doc.Add(new Field("ID", "0", Field.Store.YES, Field.Index.NO));
doc.Add(new Field("parentID", "0", Field.Store.YES, Field.Index.NO));
doc.Add(new Field("Title", "Root", Field.Store.YES, Field.Index.ANALYZED));
writer.AddDocument(doc);
writer.Optimize();
writer.Close();
Now, i want to search for the field ID
Where the value equals 0
( to get the single record i have there )....
but, a simple search like this:
Directory directory = FSDirectory.Open(new System.IO.DirectoryInfo(Server.MapPath("/data/channels")));
Analyzer analyzer = new Lucene.Net.Analysis.Standard.StandardAnalyzer(Version.LUCENE_29);
Searcher searcher = new Lucene.Net.Search.IndexSearcher(IndexReader.Open(directory, true));
Query query = new Lucene.Net.QueryParsers.QueryParser(Version.LUCENE_29, "ID", analyzer).Parse("0");
Hits hits = searcher.Search(query);
returns no results.
i have read about NumericRange
, KeywordAnalyzer
and some more things,
but since none of them provides a sample i could not figure out how to do it.
please, kind people, give me an example of how to make this thing work.