简体   繁体   中英

search in lucene index

I created a lucene(3.0.1) index on a column to search with in text, On testing on this text :

$GLD is a great example of why it does not make sense EVER to try and catch a falling knife.

It gives me result if I search by keyword "falling" but I am getting nothing on searching by "$GLD"

I am using standardAnalyzer :

String longString = "$GLD is a great example of why it does not make sense EVER to try and catch a falling knife."

Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_30);
doc.add(new Field("data", longString, Store.YES, Field.Index.ANALYZED));

Because Field.Index.ANALYZED is set it should create tokens and $GLD should be present. Analyzer will remove stop words from the text, is word $GLD is also getting removed in the process.

Your document's field is changed by Analyzer. Why don't you use Analyzer on your query before you search. Meanwhile a QueryParser would help a lot.

You should check the StandardAnalyzer , the StandardAnalyzer may remove $ and may use LowerCaseFilter in its procedure (I'm not sure, I just know 2.3 and 4.1). The LowerCaseFilter will make the words to lower case. When you search upper case letter, you won't get any thing.

You can use Luke to check the tokenized result in index.

使用Luke来检查您的查询是否达到了您的预期效果也有帮助。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM