[hibernate-dev] HSearch programmatic mapping API

Emmanuel Bernard emmanuel at hibernate.org
Sun Mar 22 22:37:46 EDT 2009


I have started working on that in the plane back home.
It's available upstream and requires the upstream commons-annotations  
and annotations projects.

       SearchMapping mapping = new SearchMapping();
       mapping.analyzerDef( "stem", StandardTokenizerFactory.class )
                .tokenizerParam( "name", "value" )
                .tokenizerParam(  "name2", "value2" )
                .filter( LowerCaseFilterFactory.class )
                .filter( SnowballPorterFilterFactory.class)
                   .param("language", "English")
             .analyzerDef( "ngram", StandardTokenizerFactory.class )
                .tokenizerParam( "name", "value" )
                .tokenizerParam(  "name2", "value2" )
                .filter( LowerCaseFilterFactory.class )
                .filter( NGramFilterFactory.class)
                   .param("minGramSize", "3")
                   .param("maxGramSize", "3")
             .indexedClass(Address.class, "Address_Index")
                .property("street1", ElementType.FIELD)
                   .field()
                   .field()
                      .name("street1_iso")
                      .store( Store.YES )
                      .index( Index.TOKENIZED )
                      .analyzer( ISOLatin1Analyzer.class)
                   .field()
                      .name("street1_ngram")
                      .analyzer("ngram")
             .indexedClass(User.class)
                .property("name", ElementType.METHOD)
                   .field()
             .analyzerDef( "minimal", StandardTokenizerFactory.class  );

        
configuration.getProperties().put( "hibernate.search.mapping_model",  
mapping );

It works nicely (analyzerDef is not wired yet) and the mapping API  
needs to be completed. A benefit is that it solves the problem  
encountered by people willing to get XML mapping support in a much  
nicer way.

It would benefit from a few additional pairs of eye before completing  
the work.

http://forum.hibernate.org/viewtopic.php?p=2409404#2409404
http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-352
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-dev/attachments/20090322/5b0e3705/attachment.html 


More information about the hibernate-dev mailing list