i've a problem doing a full text search in lucene.net where the search result contains special lucene characters.
I've a field named "content" in my Lucene documents. This field is created as followed and contains the content of the indexed documents:
document.Add(new Field("content", fulltext, Field.Store.YES, Field.Index.ANALYZED));
For creating the index i'm using the Standardanalyzer.
For querying the index i'm using the following code:
var queryParser = new QueryParser(Lucene.Net.Util.Version.LUCENE_29, "content", analayzer);
queryParser.SetAllowLeadingWildcard(true);
queryParser.SetMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);
Query fullTextQuery = queryParser.Parse(queryString);
The query is then added to a BooleanQuery which is used to get the results from a IndexSearcher. I think the rest of the code is not that important, because the code works like it should for 99% of the queries. I'm also using the StandardAnalyzer for querying the index.
Now here is the problem. Sometimes the "content" field of a document contains text that is separated using "-"
some text some text selector-lever some text some text
Now when i'm doing a full text search (exact phrase) using "selector lever". The query looks like this:
content:"selector lever"
The problem here is that also the document containing the above text is found, although it shouldn't be found because the 2 words are separated using the "-" and not blank.
I think it has something to do with the analyzer and the fact that "-" is a special character in lucene.
Maybe someone can help me solving this problem.
thanks in advance Martin