lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Rose" <mr...@freshdirect.com>
Subject behavioral differences between Field.Keyword and Field.UnStored
Date Fri, 11 Feb 2005 21:09:00 GMT
Perhaps someone can explain something that seems to be a little weird to
me.  I seem to be unable to search on fields of type Keyword.  The
following snippet returns no hits..

 

        IndexWriter index = new IndexWriter(indexPath, new
StandardAnalyzer(), true);

        

        Document doc = null;

        

        doc = new Document();

        doc.add(Field.Text("artist", "Butthole Surfers"));

        doc.add(Field.Keyword("genre",  "Punk"));

        doc.add(Field.Text("album",  "Rembrandt Pussyhorse"));

        index.addDocument(doc);

        

        doc = new Document();

        doc.add(Field.Text("artist", "Ornette Coleman"));

        doc.add(Field.Keyword("genre",  "Jazz"));

        doc.add(Field.Text("album",  "Tomorrow is the Question"));

        index.addDocument(doc);

        

        index.optimize();

        index.close();

        

        Searcher searcher = new IndexSearcher(indexPath);

        

        String expression = "genre:punk";

        Query query = QueryParser.parse(expression, "artist", new
StandardAnalyzer());

 

        Hits hits = searcher.search(query);

        for (int i = 0; i < hits.length(); i++) {

            System.out.println(hits.doc(i));

        }

        

        searcher.close();

 

 

However, if I change the "genre" field to be defined as Field.Text or
Field.UnStored, I get the result I expect.  Can anyone offer any
insight?

 

Mike

 

 

 

 

 


Mime
View raw message