[hibernate-issues] [Hibernate-JIRA] Commented: (HSEARCH-221) Get Lucene Analyzer runtime (indexing)

Emmanuel Bernard (JIRA) noreply at atlassian.com
Tue Nov 25 11:14:16 EST 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-221?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=31813#action_31813 ] 

Emmanuel Bernard commented on HSEARCH-221:
------------------------------------------

The choice of analyzer needs to be serialized and passed to the LuceneWork. I still think referencing an analyzer def is the right approach (string are serialiable and points to an already initialized analyzer).

Refining an analyzer per field is trickier

public class PassThroughDiscriminator implements Discriminator { 
    //TODO do we really need Object entity? It seems we don't
    public String getAnanyzerDefinitionName(Object value, Object entity, String field) { 
        return field != null ? (String) value : null; 
    } 
} 

When an entity marked with @AnalyzerDiscriminator is indexed,
the discriminator implementation is used and executed over:
 - field = null (entity level analyzer)
 - each field the Document object is passed through (ie each FieldBridge name)

If the discriminator is not willing to override the default analyzer, null should be returned

This generates a Map<String, String> <fieldname, analyzerdef>

This map is passed to LuceneWork and used at indexing time to apply the appropriate analyzer
(we need a scoped analyzer on top of the regular scoped DocumentBuilder.getAnalyzer())

I expect most Discriminator impl to return a specific value when field == null and return null when the field is not null
It basically implements the following rule:
 - the entity level analyzer is overridden
 - field/property level analyzer are not overridden by this new analyzer

Of course an impl can go against this rule.




> Get Lucene Analyzer runtime (indexing)
> --------------------------------------
>
>                 Key: HSEARCH-221
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-221
>             Project: Hibernate Search
>          Issue Type: Improvement
>    Affects Versions: 3.0.1.GA
>            Reporter: Kenneth Christensen
>            Assignee: Hardy Ferentschik
>             Fix For: 3.1.0
>
>         Attachments: AddLuceneWork.java, diff-jms.txt, diff.txt, DocumentBuilder.java, EntityInstanceAnalyzer.java, Flyer.java, Flyer.java, Flyer.java-JMS, hibernate-search-v2.zip, hibernate-search.zip, LuceneWorker.java, TestBean.java
>
>
> I'm writing a multi-language application and I have choose to use Hibernate Search.
> But it looks like Hibernate Search have some limitations in multi-language applications.
> I need to use the SnowballAnalyzer and create the instance at runtime because I only know the language at runtime.
> It really looks like Hibernate Search don't support runtime created analyzers for entity instances.
> I have extended Hibernate Search to support the above issue - maybe you could include the code in Hibernate Search or implement something similarly.
> I really need this feature/improvement :-)
> Please see attached files.
> Flyer - Entity used in test
> TestBean - SessionBean used in test
> org.hibernate.search.backend.impl.lucene.LuceneWorker - Added code to support entity instance analyzer, see performWork(AddLuceneWork work, DirectoryProvider provider) and add(Class entity, Serializable id, Document document, DirectoryProvider provider, Analyzer analyzer).
> org.hibernate.search.backend.AddLuceneWork - Added code to support analyzer.
> org.hibernate.search.engine.DocumentBuilder - Added code to support entity instance analyzer, see addWorkToQueue(Class entityClass, T entity, Serializable id, WorkType workType, List<LuceneWork> queue, SearchFactoryImplementor searchFactoryImplementor).

-- 
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