lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kai Hu" <kai...@dusee.cn>
Subject 答复: unable to search from a string containing numbers seperated by comma.
Date Wed, 05 Sep 2007 07:25:09 GMT
Hi,
	I have this problem too. I made a test use StandardAnalyzer:

	Analyzer analyzer = new StandardAnalyzer();
	 Reader reader = new BufferedReader(new InputStreamReader(new StringBufferInputStream("Aaa,0982,abc")));
	  TokenStream tokenStream = analyzer.tokenStream("abc",reader);
	  org.apache.lucene.analysis.Token token = tokenStream.next();
	  while(token != null){
		  System.out.println(token);
		 token = tokenStream.next();
		  }
  }

	The result is "(aaa,0982,abc,0,12,type=<NUM>)",the analyzer parsed the 
"Aaa,0982,abc" as a "NUM" type word.


-----邮件原件-----
发件人: prabin meitei [mailto:prabin.meitei@gmail.com] 
发送时间: 2007年8月30日 星期四 18:07
收件人: java-user@lucene.apache.org
主题: unable to search from a string containing numbers seperated by comma.

Hi,
  I am trying to search from an idlist (string containing comma seperated
numeric values)

eg:
QueryParser vParser = new QueryParser("idlist", new AlphanumAnalyzer()); //
analyzer using custom lettertokenizer which tokenize nuber also. class is
given below.
Query q = vParser.parse("55"); // example

now even if the field idlist contains say (44, 55, 66)
my search returns 0 hit. is there any alternative solution or is there some
problem with wat i am using.

Thanks in advance.

public class AlphanumericTokenizer extends LetterTokenizer {
  public AlphanumericTokenizer(Reader reader) {
    super(reader);
  }

  protected boolean isTokenChar(char c) {
    return super.isTokenChar(c) || Character.isDigit(c);
  }
}

---------------------------------------------------------------------
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