You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by sumittyagi <pi...@gmail.com> on 2008/02/24 07:31:08 UTC

Searcher.java ...problem in compiling

import java.io.*;
import org.apache.lucene.document.*;
import org.apache.lucene.document.Field.*;
import org.apache.lucene.index.*;
import org.apache.lucene.analysis.*;
import org.apache.lucene.analysis.standard.*;
import java.util.*;
import java.io.IOException;
import org.apache.lucene.store.*;
import org.apache.lucene.search.*;
import org.apache.lucene.queryParser.*;


public class Searcher {
public static void main(String[] args) throws Exception {
if (args.length != 2) {
throw new Exception("Usage: java " + Searcher.class.getName()
+ " <index dir> <query>");
}
File indexDir = new File(args[0]);
String q = args[1];
if (!indexDir.exists() || !indexDir.isDirectory()) {
throw new Exception(indexDir +
" does not exist or is not a directory.");
}
search(indexDir, q);
}
public static void search(File indexDir, String q)
throws Exception {
Directory fsDir = FSDirectory.getDirectory(indexDir, false);
IndexSearcher is = new IndexSearcher(fsDir);
Query query = QueryParser.parse(q, "contents",new StandardAnalyzer());
long start = new Date().getTime();
Hits hits = is.search(query);
long end = new Date().getTime();
System.err.println("Found " + hits.length() +
" document(s) (in " + (end - start) +
" milliseconds) that matched query '" +
q + "':");
for (int i = 0; i < hits.length(); i++) {
Document doc = hits.doc(i);
System.out.println(doc.get("filename"));
}
}
}
*****************************************************8
and the error i am getting is

C:\Documents and Settings\Sumit\Desktop\db>javac Searcher.java
Searcher.java:32: parse(java.lang.String) in
org.apache.lucene.queryParser.Query
Parser cannot be applied to
(java.lang.String,java.lang.String,org.apache.lucene
.analysis.standard.StandardAnalyzer)
Query query = QueryParser.parse(q, "contents",new StandardAnalyzer());
                         ^
Note: Searcher.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error



please help me out regarding these basic problems...
-- 
View this message in context: http://www.nabble.com/Searcher.java-...problem-in-compiling-tp15661355p15661355.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