lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cecil, Paula New" <c...@fuse.net>
Subject Can't locate field
Date Mon, 19 Nov 2001 02:12:03 GMT
This is my first message to this list.  I have successfully created several little tests of
the Lucene api.  In my last test, I am trying to index "data records".  Only the "primary
key" needs to be stored (and I did not even index this field).  For the others I want to index,
but neither store or tokenize (I want the the entire text string to be the "term").

So my index code looks like:
    doc.add(Field.UnIndexed("userid", dtable[i][iuserid]));
    doc.add(new Field("charge",dtable[i][icharge],false,true,false));
    doc.add(new Field("fname", dtable[i][ifname],false,true,false));
    doc.add(new Field("lname", dtable[i][ilname],false,true,false));
    doc.add(new Field("email", dtable[i][iemail],false,true,false));
    doc.add(new Field("hiredt",dtable[i][ihiredt],false,true,false));
    doc.add(new Field("title",  dtable[i][ititle],false,true,true));

The last field I tokenize and it seems to work ok.  The others never return hits.

My search code is below.  Essentially I am trying to search like this:
java ./index lname smith

Which should find everyone with a last name of "smith".  But no hits are returned.
What am I doing wrong?

Thanks


public class Search {
  public static void main(String[] args) throws Exception {
 Date start = new Date();
    String indexPath = args[0], qfield = args[1], queryString = args[2];

    Searcher searcher = new IndexSearcher(indexPath);
    Query query = QueryParser.parse(queryString, qfield,
                              new SimpleAnalyzer());
    Hits hits = searcher.search(query);

 Date stop = new Date();
 if ( args.length > 2 ) {
  for (int i=0; i<hits.length(); i++) {
    System.out.println(
     "Userid "+hits.doc(i).get("userid") +
     "; Score: " +
     hits.score(i));
  };
 }
    System.out.println("\nNumber of hits: "+ hits.length());
    long totalms = stop.getTime() - start.getTime();
 System.out.println(totalms + " total milliseconds");
  }
}

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