public EntityMapping entity(Class<?> entityType) { return new EntityMapping( entityType, mapping ); } }
public AnalyzerDefMapping analyzerDef(String name, Class<? extends TokenizerFactory> tokenizerFactory) { return analyzerDef( name, "", tokenizerFactory ); }
@Override public void defineMappings(Cache cache, SearchMapping searchMapping) { searchMapping.entity(GenericData.Record.class) .indexed() .classBridgeInstance(new ValueWrapperFieldBridge()) .norms(Norms.NO) .analyze(Analyze.NO) .store(Store.NO); } }
private FullTextSessionBuilder configure(boolean withClassBridgeOnItem, int depth, boolean withClassBridgeOnCatalog) { FullTextSessionBuilder builder = new FullTextSessionBuilder() .addAnnotatedClass( Catalog.class ) .addAnnotatedClass( CatalogItem.class ) .addAnnotatedClass( Consumer.class ) .addAnnotatedClass( Item.class ); SearchMapping fluentMapping = builder.fluentMapping(); // mapping for Catalog EntityMapping catalogMapping = fluentMapping .entity( Catalog.class ); if ( withClassBridgeOnCatalog ) { catalogMapping.classBridge( NoopClassBridge.class ); } catalogMapping .property( "catalogItems", ElementType.FIELD ).containedIn(); // mapping for CatalogItem fluentMapping.entity( CatalogItem.class ) .property( "item", ElementType.FIELD ).containedIn() .property( "catalog", ElementType.FIELD ).indexEmbedded(); // mapping for Item IndexedMapping itemMapping = fluentMapping .entity( Item.class ) .indexed(); if ( withClassBridgeOnItem ) { itemMapping.classBridge( NoopClassBridge.class ); } itemMapping.property( "catalogItems", ElementType.FIELD ).indexEmbedded().depth( depth ); return builder.build(); }
.entity(InternalProcessDefinition.class).indexed().indexName("process_definition") .property("dbid", ElementType.FIELD).documentId().name(ProcessDefinitionIndex.DBID) .entity(LightProcessDefinitionImpl.class) .bridge(StringSetFieldBridge.class) .entity(NamedElementImpl.class) .property("name", ElementType.METHOD).field().name(ProcessDefinitionIndex.NAME) .entity(DescriptionElementImpl.class) // share with All DescriptionElement: processes, groups, ... .property("description", ElementType.METHOD).field().name(ProcessDefinitionIndex.DESCRIPTION) .entity(InternalProcessInstance.class).indexed().indexName("process_instance") .property("dbid", ElementType.FIELD).documentId().name(ProcessInstanceIndex.DBID) .entity(ProcessInstanceImpl.class) .property("commentFeed", ElementType.METHOD).indexEmbedded() .property("involvedUsers", ElementType.METHOD).field().name(ProcessInstanceIndex.INVOLVED_USER) .bridge(StringSetFieldBridge.class) .property("activities", ElementType.METHOD).indexEmbedded() .property("lastKnownVariableValues", ElementType.METHOD).field().name("variable") .bridge(ObjectMapFieldBridge.class) .property("activeUsers", ElementType.METHOD).field().name(ProcessInstanceIndex.ACTIVE_USER) .entity(CommentImpl.class).indexed().indexName("comment") .property("dbid", ElementType.FIELD).documentId().name(CommentIndex.DBID) .entity(Comment.class) .property("message", ElementType.METHOD).field().name(CommentIndex.MESSAGE) .entity(InternalActivityInstance.class).indexed().indexName("activity_instance") .property("dbid", ElementType.FIELD).documentId().name(ActivityInstanceIndex.DBID) .entity(TaskInstance.class)
.indexed() .boost( 2 ) .classBridge( AddressClassBridge.class ) .property( "street2", ElementType.METHOD ) .field().name( "idx_street2" ).store( Store.YES ).boost( 2 ) .entity( ProvidedIdEntry.class ).indexed() .providedId().name( "providedidentry.providedid" ).bridge( LongBridge.class ) .property( "name", ElementType.FIELD ) .property( "age", ElementType.FIELD ) .field().name( "providedidentry.age" ).analyzer( EN_ANALYZER_NAME ).index( Index.YES ).store( Store.YES ) .entity( ProductCatalog.class ).indexed() .boost( 2 ) .property( "id", ElementType.FIELD ).documentId().name( "id" ) .includeEmbeddedObjectId( true ) .entity( Item.class ) .indexed() .property( "id", ElementType.FIELD ) .documentId() .store( Store.YES ) .entity( DynamicBoostedDescLibrary.class ) .dynamicBoost( CustomBoostStrategy.class ) .indexed() .property( "libraryId", ElementType.FIELD ) .documentId().name( "id" )
/** Built-in default programatic mapping for hibernate-search **/ private static SearchMapping getBuiltinMapping() { SearchMapping mapping = new SearchMapping(); // Map the getExternalId() method as a documentId for all domain classes // Note that hibernate-search currently requires this method to really exist in the // AbstractDomainObject class mapping.entity(AbstractDomainObject.class).property("externalId", ElementType.METHOD).documentId().name("id"); return mapping; }
@Override public void configure(Map<String,Object> cfg) { SearchMapping mapping = new SearchMapping(); mapping .entity( PlainPerson.class ) .indexed() .property( "id", ElementType.FIELD ) .documentId() .bridge( PersonPKBridge.class ) .property( "", ElementType.FIELD ) .field(); cfg.put( Environment.MODEL_MAPPING, mapping ); }
@Override public void configure(Map<String,Object> cfg) { SearchMapping mapping = new SearchMapping(); mapping .entity( PlainPerson.class ) .indexed() .property( "id", ElementType.FIELD ) .documentId() .bridge( PersonPKMetadataProviderBridge.class ) .property( "", ElementType.FIELD ) .field(); cfg.put( Environment.MODEL_MAPPING, mapping ); }
public EntityMapping entity(Class<?> entityType) { return new EntityMapping( entityType, mapping ); } }
public AnalyzerDefMapping analyzerDef(String name, Class<? extends TokenizerFactory> tokenizerFactory) { return analyzerDef( name, "", tokenizerFactory ); }
@SuppressWarnings("unchecked") private void verifyOptimizerImplementationIs(Class type, SearchConfigurationForTest cfg) { SearchMapping mapping = new SearchMapping(); mapping .entity( Document.class ).indexed() .property( "id", ElementType.FIELD ).documentId() .property( "title", ElementType.FIELD ).field() ; cfg.setProgrammaticMapping( mapping ); cfg.addClass( Document.class ); SearchIntegrator sf = integratorResource.create( cfg ); EntityIndexBinding indexBindingForEntity = sf.getIndexBindings().get( Document.class ); DirectoryBasedIndexManager indexManager = (DirectoryBasedIndexManager) indexBindingForEntity.getIndexManagerSelector().all().iterator().next(); OptimizerStrategy optimizerStrategy = indexManager.getOptimizerStrategy(); Assert.assertTrue( type.isAssignableFrom( optimizerStrategy.getClass() ) ); }
public EntityMapping entity(Class<?> entityType) { return new EntityMapping( entityType, mapping ); } }
@Factory public SearchMapping build() { SearchMapping mapping = new SearchMapping(); mapping .analyzerDef( "ngram", StandardTokenizerFactory.class ) .filter( LowerCaseFilterFactory.class ) .filter( StopFilterFactory.class ) .param( "words", "non-existent-resourcename.file" ) // We must mark at least one entity as indexed, otherwise analyzer definitions are not initialized (no need to) .entity( SomeHibernateEntity.class ).indexed(); return mapping; }
public EntityMapping entity(Class<?> entityType) { return new EntityMapping( entityType, mapping ); } }
@Test public void testTypeWithNoDocumentIdThrowsException() { SearchConfigurationForTest cfg = getManualConfiguration(); SearchMapping mapping = new SearchMapping(); mapping .entity( Foo.class ).indexed() ; cfg.setProgrammaticMapping( mapping ); try { integratorResource.create( cfg ); fail( "Invalid configuration should have thrown an exception" ); } catch (SearchException e) { assertTrue( e.getMessage().startsWith( "HSEARCH000177" ) ); } }
public EntityMapping entity(Class<?> entityType) { return new EntityMapping( entityType, mapping ); }
public void testSearchMapping() { final SearchMapping mapping = new SearchMapping(); mapping.entity(BondPVO.class).indexed() .property("id", ElementType.METHOD).field() .property("name", ElementType.METHOD).field()
public EntityMapping entity(Class<?> entityType) { return new EntityMapping( entityType, mapping ); }
@Test public void testGetIndexedTypesMultipleTypes() { SearchConfigurationForTest cfg = getManualConfiguration(); SearchMapping mapping = new SearchMapping(); mapping .entity( Foo.class ).indexed() .property( "id", FIELD ).documentId() .entity( Bar.class ).indexed() .property( "id", FIELD ).documentId() ; cfg.setProgrammaticMapping( mapping ); SearchIntegrator si = integratorResource.create( cfg ); IndexedTypeSet indexedClasses = si.getIndexedTypeIdentifiers(); assertEquals( "Wrong number of indexed entities", 2, indexedClasses.size() ); }