lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gasi" <>
Subject problems with lucene on a webhost account
Date Fri, 16 Sep 2005 21:32:09 GMT
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]));

The another one for searching:

<%@ page import = "  javax.servlet.*, javax.servlet.http.*,*, org.apache.lucene.analysis.*,
org.apache.lucene.document.*, org.apache.lucene.index.*,*, org.apache.lucene.queryParser.*,"

    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(;
        Analyzer analyzer = new StopAnalyzer(); 
        query = QueryParser.parse(myQuery,"textfeld",analyzer);
        hits =;
        if (hits.length() == 0) { 
<p> Nothing found </p>
<p>Some results found</p>
    for(int i=0;i<hits.length();i++)
     Document doc = hits.doc(i);
     String textfeld = doc.get("textfeld");

This is a very simple example for newbies in lucene, I hope this will be a little helpful
for somebody.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message