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 <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to