Click here to Skip to main content
14,302,372 members
Rate this:
Please Sign up or sign in to vote.
See more:
I’m using Lucene.Net 3.0.3.0 version in my website to search list of courses.
I have few courses which contains the special character “#” like, C#, C#.Net, etc.

But When I search with the term “C#” it showing 0 results.

I’m using StandardAnalyzer and MultiFieldQueryParser also allowing wildcard search (AllowLeadingWildcard = true).

[duplicate code removed]

Kindly let me know what I have to do to retrieve the result when I search with the term “C#”.

Thanks,
Singaravelu R

What I have tried:

var analyzer = new StandardAnalyzer(Version.LUCENE_30, stopWords);
{
	BooleanQuery query = new BooleanQuery();
	var nameParser = new MultiFieldQueryParser(Version.LUCENE_30, new[] { "Column1", " Column2", " Column3" }, analyzer);
	if (!string.IsNullOrEmpty(searchCriteria.CourseName))
	{
		query.Add(parseQuery(GetTerms(searchCriteria.CourseName.ReplaceDiacritics()), nameParser), Occur.MUST);
	}

	ScoreDoc[] hits = searcher.Search(query, null, hits_limit, Sort.RELEVANCE).ScoreDocs;
	var results = _mapLuceneToDataList(hits, searcher);
	analyzer.Close();
	searcher.Dispose();
	return results;
}

For indexing: The word “C#” indexed and stored correctly.
doc.Add(new Field("Title", 
                  sampleData.CourseName, 
                  Field.Store.YES, 
                  Field.Index.ANALYZED));
Posted
Updated 4-Sep-17 0:35am
v2
Comments
BillWoodruff 31-Aug-17 15:37pm
   
What's wrong with the current answer to the same question you posted yesterday on the Lucerne issue-tracker:

https://issues.apache.org/jira/browse/LUCENENET-595

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Yes I have created my own Analyzer by the suggestion provided in the Lucene issue tracker "https://issues.apache.org/jira/browse/LUCENENET-595".

Now its working well.

Thanks,
Singaravelu
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100