lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 22987] - QueryParser not working on trivial query
Date Thu, 11 Sep 2003 10:43:09 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22987>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22987

QueryParser not working on trivial query





------- Additional Comments From pifpafpuf@gmx.de  2003-09-11 10:43 -------
An example is pasted in below. To see
the different behaviours, run as:

  java LucBug ID:123
  java LucBug 'ID:123*'

By now I learned that SimpleAnalyzer drops numbers. It
was obviously not a good idea to use a SimpleAnalyzer.
Nevertheless I would expect consistent behaviour.

  Harald.

import org.apache.lucene.queryParser.*;
import org.apache.lucene.search.*;
import org.apache.lucene.analysis.SimpleAnalyzer;
import org.apache.lucene.search.Hits;
import org.apache.lucene.document.*;
import org.apache.lucene.index.*;
import java.io.IOException;

public class LucBug {
  public static void main(String[] argv) 
    throws IOException, ParseException {
    String indexDir = "idnex";

    IndexWriter w = new IndexWriter(indexDir, new SimpleAnalyzer(), true);
    Document d = new Document();
    
    Field f = new Field("ID", "123", true, true, false);
    d.add(f);
    w.addDocument(d);
    w.close();

    Query q = QueryParser.parse(argv[0], "ID", new SimpleAnalyzer());
    IndexSearcher search = new IndexSearcher(indexDir);
    Hits h = search.search(q);
    for(int i=0; i<h.length(); i++) {
      System.out.println(h.doc(i));
    }
  }
}

Mime
View raw message