Category: Open Source

How to search a Lucene.Net index in C#

Benjamin Perkins Lucene.NET

I used this code to perform a search of a Lucene.Net index. Lucene.Net.Store..Directory directory =      Lucene.Net.Store.FSDirectory                .Open(new DirectoryInfo(textBoxSearchIndex.Text)); Lucene.Net.Analysis.Analyzer analyzer =      new Lucene.Net.Analysis.Standard                    .StandardAnalyzer(LuceneUtil.Version.LUCENE_29); Lucene.Net.Search.Searcher searcher =      new Lucene.Net.Search                .IndexSearcher(LuceneIndex.IndexReader                                          .Open(directory, true)); Lucene.Net.Search.Query query =      new Lucene.Net.QueryParsers                .QueryParser(LuceneUtil.Version.LUCENE_29,                             “contents”, analyzer)                             .Parse(textBoxSearch.Text); Lucene.Net.Search.Hits hits = […]

Read More →

Lucene.NET returns results only when using numeric values

Benjamin Perkins Lucene.NET

I used this code to create a Lucene.Net 2.9.2 index. System.IO.DirectoryInfo indexFileLocation = new System.IO.DirectoryInfo(textBox1.Text); Lucene.Net.Store.Directory directory = Lucene.Net.Store.FSDirectory.Open(indexFileLocation); Lucene.Net.Analysis.Analyzer analyzer = new Lucene.Net .Analysis .Standard .StandardAnalyzer(LuceneUtil.Version.LUCENE_29); IndexWriter writer = new IndexWriter(directory, analyzer, true, IndexWriter.MaxFieldLength.UNLIMITED); foreach (IList item in dataToIndex) { Document doc = new Document(); doc.Add(new Field(“ID”, item[0].ToString(), Field.Store.YES, Field.Index.NO)); …. string contents = […]

Read More →

Nhibernate GenericADOException could not execute query

NHibernate Benjamin Perkins

During the mapping process or after a data model change you may receive this error. The error message being: {“could not execute query\r\n[ select from TABLE ]”} with an inner exception of {“Ungültiger Spaltenname ‘SPALTEN NAME’.”} {“Invalid column name ‘COLUMN NAME’.”} I received this error when I was creating a many-to-one relationship between 2 classes, […]

Read More →

NHibernate MappingException association references unmapped class

NHibernate Benjamin Perkins

During the mapping process you may encounter this error. In my situation the case was that I had the wrong namespace identified within the class attribute within a bag element containing a one-to-many element, like the below. <bag name=”Customer”>    <key column=”CUST_ID” />    <one-to-many class=”CompanyName.SysName.Nhibernate.Common.Customer” /> </bag> Instead of Common I had another directory […]

Read More →