We use Examine to index a database with rule definitions. Recently I became aware that for a basic search phrase, such as "admission motion" works fine, but as soon as I add a two character word in the middle such as "admission on motion", we get a NULL reference error:
[NullReferenceException: Object reference not set to an instance of an object.]
Lucene.Net.Search.BooleanQuery.Rewrite(IndexReader reader) +353
Lucene.Net.Search.BooleanQuery.Rewrite(IndexReader reader) +367
Lucene.Net.Search.IndexSearcher.Rewrite(Query original) +29
Lucene.Net.Search.Query.Weight(Searcher searcher) +52
Lucene.Net.Search.Searcher.Search(Query query, Filter filter, Int32 n, Sort sort) +29
Examine.LuceneEngine.SearchResults.DoSearch(Query query, IEnumerable`1 sortField) +258
Examine.LuceneEngine.Providers.BaseLuceneSearcher.Search(ISearchCriteria searchParams) +181
Ethics.DAL.EthicsDB.getSearchedOpinions(String searchPhrase) +3109
Ethics.Opinions.Page_Load(Object sender, EventArgs e) +682
At first look, I cannot see anything wrong with my code. Thoughts?
Which analyser are you using to create the index? Your Examine config file will have the definition. If using standard then all english stop words will be removed.
If you are getting a null reference error then this may be something todo with one of the search results not having a field value so in your loop where you fill the datatable its erroring. I would step through the code and see if that is the case.
Also I would get a copy of the generated lucene query and run it in luke and see what you get back this may also indicate what the problem is.
I had this problem myself. Try looking at your lucene query, you might be able to find entries like "()" at some places.
In my scenario, when Lucene found a "()" it died
These empty parenthesis occured for me when the standard analyzer was working with words like "for, and, on, of, etc." (the stopwords in the Standard Analyzer).
In Global.asax try pasting in the following code in your OnApplicationStarted() method.
Lucene.Net.Analysis.StopAnalyzer.ENGLISH_STOP_WORDS_SET = new System.Collections.Hashtable();
It removes the stopwords, and was one of the keys for solving my problem back then.
All that being said. If you could provide the Lucene query it would help us a lot helping you ;)
Examine Search Fails for two character words
We use Examine to index a database with rule definitions. Recently I became aware that for a basic search phrase, such as "admission motion" works fine, but as soon as I add a two character word in the middle such as "admission on motion", we get a NULL reference error:
At first look, I cannot see anything wrong with my code. Thoughts?
Connie,
Which analyser are you using to create the index? Your Examine config file will have the definition. If using standard then all english stop words will be removed.
If you are getting a null reference error then this may be something todo with one of the search results not having a field value so in your loop where you fill the datatable its erroring. I would step through the code and see if that is the case.
Also I would get a copy of the generated lucene query and run it in luke and see what you get back this may also indicate what the problem is.
Regards
Ismail
It looks like I am not specifying which analyser so I must be using a default one?
The error is occurring when the filter is passed, even before getting to adding the results to the table.
It seems to be narrowed down to one line...
of the else portion of...
That line fails on the noise words like for, and, on, of, etc.
I had this problem myself. Try looking at your lucene query, you might be able to find entries like "()" at some places.
In my scenario, when Lucene found a "()" it died
These empty parenthesis occured for me when the standard analyzer was working with words like "for, and, on, of, etc." (the stopwords in the Standard Analyzer).
In Global.asax try pasting in the following code in your OnApplicationStarted() method.
It removes the stopwords, and was one of the keys for solving my problem back then.
All that being said. If you could provide the Lucene query it would help us a lot helping you ;)
is working on a reply...