This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Try this (notice that the search terms are in *lowercase*):
Try this too (notice that search terms are as they are):
The Analyzer you choose is critical - read the javadoc of StandardAnalyzer and you'll find it involves a LowerCaseFilter.
You have to decide for your application whether Managing = managing = MaNaGing.
- Choose an analyzer that doesn't make any modifications you're not expecting, OR
- Based on analyzer javadocs, enforce modifications on your search term (i.e, since you've read StandardAnalyzer javadocs and you know in your mind that it applies a lowercase filter, you do a toLower() on your search terms). This is bad approach because the rules of analyzer are being duplicated in your code.
- Best approach: Apply the same Analyzer that you use to index, on your query too, using the QueryParser class. In future, if you change your indexing Analyzer, the queries will auto conform to its rules.
Use Luke tool to analyze your indices. It tells you the terms stored and a lot more. For debugging ease, it's better to work on a file based index during development till your basic indexing and querying are verified ok.