lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mitu2009 <musicfrea...@gmail.com>
Subject Re: Handling + as a special character in Lucene search
Date Fri, 23 Oct 2009 16:37:32 GMT

Code details: When I execute this line,I get a blank search query.

queryField =
multiFieldQueryParser.Parse(inpKeywords);keywordsQuery.Add(queryField,
BooleanClause.Occur.SHOULD);And here is my custom analyzer:

public class CustomAnalyzer : Analyzer    {        private static readonly
WhitespaceAnalyzer whitespaceAnalyzer = new WhitespaceAnalyzer();    public
override TokenStream TokenStream(String fieldName, System.IO.TextReader
reader)        {            TokenStream result =
whitespaceAnalyzer.TokenStream(fieldName, reader);            result = new
StandardTokenizer(reader);            result = new LowerCaseFilter(result);           
result = new StopFilter(result, stop_words);            return result;       
}}And I'm executing search query this way:

indexSearcher.Search(searchQuery, collector);QueryParser has Escape(string
s) method but MultiFieldQueryParser does not seem to have one.Am using
Lucene.net version 2.1.0.3


Thanks for reading.



mitu2009 wrote:
> 
> How do i make sure lucene gives me back relevant search results when my
> input string contains terms like c++? Lucene seems to ignore ++
> characters.
> 
> Code details: When I execute this line,I get a blank search query.
> 
> queryField =
> multiFieldQueryParser.Parse(inpKeywords);keywordsQuery.Add(queryField,
> BooleanClause.Occur.SHOULD);And here is my custom analyzer:
> 
> public class CustomAnalyzer : Analyzer    {        private static readonly
> WhitespaceAnalyzer whitespaceAnalyzer = new WhitespaceAnalyzer();   
> public override TokenStream TokenStream(String fieldName,
> System.IO.TextReader reader)        {            TokenStream result =
> whitespaceAnalyzer.TokenStream(fieldName, reader);            result = new
> StandardTokenizer(reader);            result = new
> LowerCaseFilter(result);            result = new StopFilter(result,
> stop_words);            return result;        }}And I'm executing search
> query this way:
> 
> indexSearcher.Search(searchQuery, collector);
> 
> QueryParser has Escape(string s) method but MultiFieldQueryParser does not
> seem to have one.Am using Lucene.net version 2.1.0.3
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Handling-%2B-as-a-special-character-in-Lucene-search-tp26002815p26029632.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message