lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Otis Gospodnetic <otis_gospodne...@yahoo.com>
Subject Re: behavioral differences between Field.Keyword and Field.UnStored
Date Fri, 11 Feb 2005 21:15:16 GMT
The QueryParser is analyzing your Field.Keyword (genre field) fields,
because it doesn't know that genre is a Keyword field and should not be
analyzed.

Check section 4.4. here:
  http://www.lucenebook.com/search?query=queryparser+keyword

Otis
 

--- Mike Rose <mrose@freshdirect.com> wrote:

> 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
> 
>  
> 
>  
> 
>  
> 
>  
> 
>  
> 
> 

> ATTACHMENT part 2 application/x-pkcs7-signature name=smime.p7s



---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message