lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sumittyagi <ping.su...@gmail.com>
Subject Searcher.java ...problem in compiling
Date Sun, 24 Feb 2008 06:30:20 GMT

i am using lucene 2.2.0 and having problems in compiling the basic programs,
please help me out

the code is
*******************************************************8

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-tp15661353p15661353.html
Sent from the Lucene - Java Developer mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message