Posted By:
Van_Nguyen
Posted On:
Thursday, May 18, 2006 12:03 PM
I am trying to get lucene to execute a PhraseQuery or a FuzzyQuery. Here's my code: String dir = "C:/shared/sku_all_dc"; File indexDir = new File(dir); Directory fsDir = FSDirectory.getDirectory(indexDir, false); IndexSearcher is = new IndexSearcher(fsDir); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); while (true) { System.out.print("Query: "); String line = in.readLine().toUpperCase(); PhraseQuery phraseQuery = new PhraseQuery(); phraseQuery.setSlop(1); for (int i=0; i < searchFields.length; i++) { phraseQuery.add(new Term("description_short", searchFields[i])); }
More>>
I am trying to get lucene to execute a PhraseQuery or a FuzzyQuery. Here's my code:
String dir = "C:/shared/sku_all_dc";
File indexDir = new File(dir);
Directory fsDir = FSDirectory.getDirectory(indexDir, false);
IndexSearcher is = new IndexSearcher(fsDir);
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
while (true)
{
System.out.print("Query: ");
String line = in.readLine().toUpperCase();
PhraseQuery phraseQuery = new PhraseQuery();
phraseQuery.setSlop(1);
for (int i=0; i
< searchFields.length; i++)
{
phraseQuery.add(new Term("description_short", searchFields[i]));
}
Hits hits = is.search(phraseQuery);
}
This returns zero hits. But if I comment out all the PhraseQuery stuff, and just put in this:
Query query = QueryParser.parse(line, "description_short", new StandardAnalyzer());
It returns will results from the index.
Am I missing anything??
<<Less