Hello
I tried to index a database
""
import org.apache.lucene.demo.FileDocument;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.util.Version;
import java.sql.*;
import java.util.Properties;
import org.apache.lucene.document.*;
import java.io.*;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
public class Con{
public static void main(String[] args) throws Exception
{
final File INDEX_DIR = new File("index");
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn =
DriverManager.getConnection("jdbc:mysql://127.0.0.1/test", "root",
"passwort");
StandardAnalyzer analyzer = new StandardAnalyzer(null);
IndexWriter writer = new IndexWriter(INDEX_DIR, analyzer,
true);
System.out.println("Indexing to directory '" + INDEX_DIR +
"'...");
indexDocs(writer, conn);
writer.optimize();
writer.close();
}
private static void indexDocs(IndexWriter writer, Connection conn) throws
Exception {
String sql = "select c_id, city from city";
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
Document d = new Document();
d.add(new Field("c_id", rs.getString("c_id"), Field.Store.YES,
Field.Index.NO));
d.add(new Field("city", rs.getString("city"), Field.Store.NO,
Field.Index.ANALYZED));
writer.addDocument(d);
}
}
}
"""
and i get this message
""
symbol : constructor
IndexWriter(java.io.File,org.apache.lucene.analysis.standard.StandardAnalyzer,boolean)
location: class org.apache.lucene.index.IndexWriter
IndexWriter writer = new IndexWriter(INDEX_DIR, analyzer,
true);
^
1 error
What i am doing wrong??
I'm a newbie ...
Thank U
--
View this message in context:
http://old.nabble.com/index-a-database-tp27358959p27358959.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]