-->
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: ScopedAnalyzer contains PassThroughAnalyzer on Class Level
PostPosted: Mon Nov 08, 2010 12:46 pm 
Newbie

Joined: Wed May 31, 2006 2:34 pm
Posts: 9
Hi,

I am trying to figure out, why my QueryParser doesn't parse with the correct analyzer. I noticed, that ScopedAnalyzer is used, to handle the different analyzers, which are field dependent.

The problem is, that the ScopedAnalyzer contains only PassThroughAnalyzers, when the analyzer of the entity is defined at class level with @Analyzer. Only the fields marked with @Field(analyzer = @Analyzer(...)) are represented by a DelegateNamedAnalyzer.

Is it a bug or do I use the api wrong?

This is the way, I get the analyzer of a class (Profile in this example):

Code:
Search.getFullTextEntityManager(this.entityManager).getSearchFactory().getAnalyzer(Profile.class);


BTW: Is there a way available to get an anylzer instance, which is defined by an @AnalyzerDef annotation? I do all of the above, just to get an anylzer with a special synonymfilter for the QueryParser.

Thank you.
Timo


Top
 Profile  
 
 Post subject: Re: ScopedAnalyzer contains PassThroughAnalyzer on Class Level
PostPosted: Tue Nov 09, 2010 9:44 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi Timo,

the ScopedAnalyzer should take care transparently which analyzer to chose (also at query time). If the field name you are trying to index does not specify a more specific analyzer the global analyzer (which is the analyzer you defined on class level) is used. I don't think that the ScopedAnalyzer should only contain PassThroughAnalyzers.
Maybe you can put your question into some context. What usecase do you try to solve? How does your configuration look like and your query building code?

--Hardy


Top
 Profile  
 
 Post subject: Re: ScopedAnalyzer contains PassThroughAnalyzer on Class Level
PostPosted: Mon Nov 15, 2010 6:06 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
BTW: Is there a way available to get an anylzer instance, which is defined by an @AnalyzerDef annotation? I do all of the above, just to get an anylzer with a special synonymfilter for the QueryParser.


It seem you missed the easy way ;)

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


Top
 Profile  
 
 Post subject: Re: ScopedAnalyzer contains PassThroughAnalyzer on Class Level
PostPosted: Tue Nov 16, 2010 8:48 am 
Newbie

Joined: Wed May 31, 2006 2:34 pm
Posts: 9
Hi,

yes, the easy way is sometimes the best way. In the end I am using now the getAnalyzer() method to get the analyzer and use it to create a TokenStream:

Code:
TokenStream stream = analyzer.tokenStream(field, reader);


Anyhow, originally I wanted QueryParser to automatically select the right analyzer for the specified field, which didn't work, because the ScopedAnalyzer only contains instances of PassThroughAnalyzer, when the @Analyzer is defined on class/type level.

When fields are annotated with @Analyzer, then instances of DelegateNameAnalyzer are within the ScopedAnalyzer and the QueryParser uses the correct analyzer. This seems to me like a bug, because I would expect, that an class level analyzer is used on every field in its class.

_________________
Timo


Top
 Profile  
 
 Post subject: Re: ScopedAnalyzer contains PassThroughAnalyzer on Class Level
PostPosted: Tue Nov 16, 2010 11:02 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
yes it might be a bug: please open a JIRA issue and attach a testcase. Of course fixes are welcome too.

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


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.