[hibernate-issues] [Hibernate-JIRA] Created: (HSEARCH-609) Able to annotate @AnalyzerDiscriminator to more than one field.

Smallufo Huang (JIRA) noreply at atlassian.com
Tue Oct 19 10:10:48 EDT 2010


Able to annotate @AnalyzerDiscriminator to more than one field.
---------------------------------------------------------------

                 Key: HSEARCH-609
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-609
             Project: Hibernate Search
          Issue Type: Improvement
          Components: analyzer
    Affects Versions: 3.2.1
         Environment: search 3.2.1 , core-3.5.6
            Reporter: Smallufo Huang


Today , I found I cannot annotate more than one @AnalyzerDiscriminator in a class.
I feel it is very *not* intuitive. And it will make the Discriminator implementation more complicated. Because Discriminator will need to more judge *field* to decide correct analyzer , especially when the two fields are of different types.

{code:title=Sample1.java}
class Sample1
{
  @Field
  @AnalyzerDiscriminator(impl = LanguageDiscriminator.class)
  private String title;

  @Field
  @AnalyzerDiscriminator(impl = AnotherDiscriminator.class)
  private String content;
}
{code}
{code:title=Sample2.java}
class Sample2
{
  @Field
  @AnalyzerDiscriminator(impl = AnotherDiscriminator.class)
  private String title;
}
{code}

See the two classes for example. 
I cannot add two @AnalyzerDiscriminator in one class , and it throws {color:red}"Multiple AnalyzerDiscriminator defined in the same class hierarchy"{color} Exception.

So I have to combine LanguageDiscriminator and AnotherDiscriminator into one and use it in the 1st example. And judge Analyzer by field name : 'title' for language analyzer , and 'content' for another analyzer.

but I cannot re-use the *'CombinedDiscriminator'* to the 2nd example , because in 2nd example , the 'title' should apply AnotherDiscriminator , not LanguageDiscriminator in 1st example.


So I suggest , a class should be able to apply different Discriminators to different fields. And the Discriminator's methods should be :
{code}
public String getAnalyzerDefinitionName(Object value, Object entity) ; // remove field
{code}
It will be more flexible.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list