Hallo everybody, I had a problem with lucene demo on my webhosting account. Because I think more people have the same problem,and perhaps somebody will get the same problem in the futurek, so now I want describe how I solved it!
Well in my case I used a lucene webdemo on my homepc with windows xp and tomcat 3.3.2. the lucene webdemo worked perfectly on my homepc. After uploading these on a real webserver , it didn't work because for every search I had null results. So I found a solution-not a good one-but it works: I indexed my data on the webhostingaccount. Of course it is a bad solution, because for big amounts of data it is complicated to upload all documents you need. But for test cases it works. Here are my scripts: The one for index: <%@ page import=" org.apache.lucene.analysis.Analyzer,org.apache.lucene.analysis.standard.StandardAnalyzer,org.apache.lucene.document.Document,org.apache.lucene.document.Field,org.apache.lucene.index.IndexWriter" %> <% String[] text = { "index", "lucene","ramon","gasi" }; String indexDir = "path/onthe/webserver"; Analyzer analyzer = new StandardAnalyzer(); boolean create = true; IndexWriter writer = new IndexWriter(indexDir, analyzer, create); for (int i = 0; i < text.length; i++) { Document document = new Document(); document.add(Field.Text("textfeld", text[i])); writer.addDocument(document); } writer.close(); %> The another one for searching: <%@ page import = " javax.servlet.*, javax.servlet.http.*, java.io.*, org.apache.lucene.analysis.*, org.apache.lucene.document.*, org.apache.lucene.index.*, org.apache.lucene.search.*, org.apache.lucene.queryParser.*,java.net.URLEncoder" %> <% String indexName ="path/onthe/webserver"; //local copy of the configuration variable IndexSearcher searcher = null; //the searcher used to open/search the index Query query = null; String myQuery="lucene"; Hits hits = null; searcher = new IndexSearcher(IndexReader.open(indexName)); Analyzer analyzer = new StopAnalyzer(); query = QueryParser.parse(myQuery,"textfeld",analyzer); hits = searcher.search(query); if (hits.length() == 0) { %> <p> Nothing found </p> <% } else { %> <p>Some results found</p> <% for(int i=0;i<hits.length();i++) { Document doc = hits.doc(i); String textfeld = doc.get("textfeld"); out.println(textfeld); } } %> This is a very simple example for newbies in lucene, I hope this will be a little helpful for somebody. Greetings Gaston