-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Confusion with Standard Analyzer
PostPosted: Mon Feb 25, 2008 9:45 pm 
Newbie

Joined: Wed Feb 20, 2008 6:42 pm
Posts: 14
Hi,
Is it just me, or everybody know how to get around this issue ? Basically I am having a persistence class more or less like this:

Code:
@Entity
@Indexed
@Table(name = "products")
@SequenceGenerator(name = "products_seq", sequenceName = "products_seq")
public class Product {
  @DocumentId
  private Long productId;
  @Field(index = Index.TOKENIZED, store = Store.NO)
  private String productNm;
  @Field(index = Index.UN_TOKENIZED, store = Store.NO)
  private String catalogKy;
}

I indexed the class and every thing is ok, I could open the index using Luke and every thing seems to be fine. My retrieval code is this :
Code:
   QueryParser parser = new QueryParser("catalogKy", new StandardAnalyzer());
    Query luceneQuery = parser.parse("catalogKy:086244CK0101");

This was just not giving me the hit. The problem, I thought, I found was, when I was querying using the standard analyzer it was changing the entire value to lower case (086244ck0101), but if I open the index file in Luke it was showing me the original value (086244CK0101). But the below query was successful (with all numeric values):
Code:
   QueryParser parser = new QueryParser("catalogKy", new StandardAnalyzer());
    Query luceneQuery = parser.parse("catalogKy:086244120101");


Its happening only with the un tokenized columns. Am I missing some basic thing ? I searched the forums for this kind of problem with no success. Any help is greatly appreciated.

thanks
Anil.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 26, 2008 2:07 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
A Lucene Query parser will apply the analyzer (ie tokenize) to the query. So querying an untokenize field with the query parser is not reliable.

You can write a Lucene query programmatically (in your case a TermQuery) to avoid the analyzer work.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 26, 2008 2:51 pm 
Newbie

Joined: Wed Feb 20, 2008 6:42 pm
Posts: 14
Thanks a lot Emmanuel,
that should resolve my issue.

thanks
Anil.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.