-->
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.  [ 4 posts ] 
Author Message
 Post subject: Index query apostrophe
PostPosted: Tue Nov 27, 2012 1:43 pm 
Regular
Regular

Joined: Thu Jun 16, 2011 12:03 pm
Posts: 94
Hi all,

I need to query my index with a querystring containing an apostrophe.

I would like to retrieve the same results if I query with l'auca or auca querystring.

This is my field definition:

Code:
   /** The title. */
       @Field(name = "title_filter") // here I can use , analyzer=@Analyzer(....) maybe that solves the problem
   private String titulo;


I am searching using the title_filter field.

Thanks in advance,


Top
 Profile  
 
 Post subject: Re: Index query apostrophe
PostPosted: Tue Nov 27, 2012 8:18 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
just use the standard analyzer, both on the @Field and on the input to the Query (we do that automatically if you use the Query DSL)

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


Top
 Profile  
 
 Post subject: Re: Index query apostrophe
PostPosted: Fri Dec 07, 2012 8:50 am 
Regular
Regular

Joined: Thu Jun 16, 2011 12:03 pm
Posts: 94
Hi!

I have been trying to make it work but for the moment it doesn't work. If I search l'auca it works but I would like to search for auca and get the same results. I have checked my index with luke and the field is indexed with apostrophe (l'auca).

This is my field definition:

Code:
       @Field(name = "title", analyzer=@Analyzer(impl=StandardAnalyzer.class))
   private String titulo;


This is my query creation:

Code:
org.apache.lucene.queryParser.QueryParser parser = new QueryParser(Version.LUCENE_31, campos[cont], new StandardAnalyzer(Version.LUCENE_31) );


any help would be very appreciated :)

Thanks in advance,

Hibernator.


Top
 Profile  
 
 Post subject: Re: Index query apostrophe
PostPosted: Tue Jan 08, 2013 6:38 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
One thing I could think about is that you are not using the same Lucene version when you create the standard analyzer. In the query you are using you use Version.LUCENE_31, but depending on the Search version you are actually using it should probably be Version.LUCENE_36.

@Analyzer(impl=StandardAnalyzer.class) will under the hood use the version of the current Lucene version used by Hibernate Search unless you specify explicitly hibernate.search.lucene_version in your configuration.

That said, you can avoid all the hassle if you are using @AnalyzerDef to create a named analyzer which you then can use in your annotations as well as in the query creation via SearchFactory#getAnalyzer(String name). Or you could try the query DSL.

--Hardy


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