-->
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.  [ 5 posts ] 
Author Message
 Post subject: Analyzer Does Not LowerCase Word
PostPosted: Mon Mar 07, 2011 6:35 pm 
Beginner
Beginner

Joined: Wed Feb 09, 2011 6:49 am
Posts: 22
Hi, I am applying a StandardAnalyzer to an Entity but it does not store the value as a lower case String. The code is as Follows:

Code:
@Embeddable
@Analyzer(impl = StandardAnalyzer.class)
@Entity
@Name("contact")
@Table(name="CONTACT")
public class Contact implements Serializable {

   private Long id;
   private String firstname;

        @Id
   @GeneratedValue(generator = "foreignGenerator")
   @GenericGenerator(name = "foreignGenerator", strategy = "foreign", parameters = @Parameter(name = "property", value = "profile"))

   @Column(name="CONTACT_ID")
   public Long getId() {
      return id;
   }

        @Field(index = Index.UN_TOKENIZED, store = Store.YES)
   @NotNull
   public String getFirstname() {
      return firstname;   
   }

}


using
hibernate-search:jar:3.0.1.GA
lucene-core:jar:2.3.0

Any ideas welcome.

Thanks


Last edited by HibSearchUser80 on Mon Mar 07, 2011 7:02 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Analyzer Does Not LowerCase Word
PostPosted: Mon Mar 07, 2011 6:53 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
UN_TOKENIZED means that the text is not tokenized nor analysed, just indexed as is. It should be used only for keywords and special text that you don't want it to mess with.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Analyzer Does Not LowerCase Word
PostPosted: Mon Mar 07, 2011 7:22 pm 
Beginner
Beginner

Joined: Wed Feb 09, 2011 6:49 am
Posts: 22
Hi Sanne,

Thanks. Did try that:
Code:
       
   @Field(index = Index.TOKENIZED, store = Store.YES)
   @Analyzer(impl = StandardAnalyzer.class)
   @NotNull
   public String getFirstname() {
      return firstname;   
   }


But it still failed to lower case the value

Thanks


Top
 Profile  
 
 Post subject: Re: Analyzer Does Not LowerCase Word
PostPosted: Tue Mar 08, 2011 7:00 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,
another thing: how do you know it's not being lowercased?
When you use Store.YES you are storing the original value, so that you can extract it back from the index unchanged. What is indexed however is analyzed, so for example in your case the string "Hello World" would:
1) return "Hello World" (exactly) when using projection on that firstname field.
2) match queries against "hello", "Hello", "HELLO", "world", "World", "Hello World" and even "wORLD heLLO".
to verify how it's indexed, use Luke http://code.google.com/p/luke/, it has a nice gui which is able to open your index and show the content.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Analyzer Does Not LowerCase Word
PostPosted: Tue Mar 08, 2011 10:26 am 
Beginner
Beginner

Joined: Wed Feb 09, 2011 6:49 am
Posts: 22
Hi,

Thanks Sanne. Completely understand now. Yes was using Luke to view the index and that lead me to believe it wasn't being lower cased, however tests proved that correct results were being returned.

Works as expected now.

Thankyou very much for your help :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.