mapping .entity(InternalProcessDefinition.class).indexed().indexName("process_definition") .property("dbid", ElementType.FIELD).documentId().name(ProcessDefinitionIndex.DBID) .entity(LightProcessDefinitionImpl.class) .property("uuid", ElementType.FIELD).field().name(ProcessDefinitionIndex.UUID) .bridge(UUIDFieldBridge.class) .property("categoryNames", ElementType.METHOD).field().name(ProcessDefinitionIndex.CATEGORY_NAME) .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(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) .bridge(StringSetFieldBridge.class) .entity(LightProcessInstanceImpl.class) .property("nb", ElementType.FIELD).field().name(ProcessInstanceIndex.NB) .property("startedBy", ElementType.METHOD).field().name(ProcessInstanceIndex.STARTED_BY) .property("endedBy", ElementType.METHOD).field().name(ProcessInstanceIndex.ENDED_BY) .property("startedDate", ElementType.METHOD).field().name(ProcessInstanceIndex.STARTED_DATE) .index(Index.UN_TOKENIZED).dateBridge(Resolution.MILLISECOND) .property("endedDate", ElementType.METHOD).field().name(ProcessInstanceIndex.ENDED_DATE) .index(Index.UN_TOKENIZED).dateBridge(Resolution.MILLISECOND)
@Test public void usingConfigurationTypeOverride() { SearchMapping mapping = new SearchMapping(); mapping .entity( Book.class ).indexed() //Entity missing both @DocumentId and @ProvidedId: .property( "title", ElementType.FIELD ).field() .property( "text", ElementType.FIELD ).field() ; SearchConfigurationForTest cfg = new SearchConfigurationForTest() .setProgrammaticMapping( mapping ) .setIdProvidedImplicit( true ) .addClass( Book.class ); storeBooksViaProvidedId( cfg, ProvidedId.defaultFieldName, false ); }
@Test public void exceptionThrownWhenNotEnabled() { SearchMapping mapping = new SearchMapping(); mapping .entity( Book.class ).indexed() //Entity missing both @DocumentId and @ProvidedId: .property( "title", ElementType.FIELD ).field() .property( "text", ElementType.FIELD ).field() ; SearchConfigurationForTest cfg = new SearchConfigurationForTest() .setProgrammaticMapping( mapping ) .addClass( Book.class ); exceptions.expect( SearchException.class ); exceptions.expectMessage( "HSEARCH000177" ); storeBooksViaProvidedId( cfg, ProvidedId.defaultFieldName, false ); }
@Test public void usingDefaultSettings() { SearchMapping mapping = new SearchMapping(); mapping .entity( Book.class ).indexed() .providedId().name( "myID" ) //Entity missing both @DocumentId and @ProvidedId: .property( "title", ElementType.FIELD ).field() .property( "text", ElementType.FIELD ).field() ; SearchConfigurationForTest cfg = new SearchConfigurationForTest() .setProgrammaticMapping( mapping ) //.setIdProvidedImplicit( false ) //Test it's the default .addClass( Book.class ); storeBooksViaProvidedId( cfg, "myID", false ); }
@Test public void usingExplicitProvidedId() { SearchMapping mapping = new SearchMapping(); mapping .entity( Book.class ).indexed() .providedId().name( "myID" ) //Entity missing both @DocumentId and @ProvidedId: .property( "title", ElementType.FIELD ).field() .property( "text", ElementType.FIELD ).field() ; SearchConfigurationForTest cfg = new SearchConfigurationForTest() .setProgrammaticMapping( mapping ) .setIdProvidedImplicit( false ) //DEFAULT .addClass( Book.class ); storeBooksViaProvidedId( cfg, "myID", false ); }
@Test public void usingProvidedIdAsOptionsOverride() { SearchMapping mapping = new SearchMapping(); mapping .entity( Book.class ).indexed() .providedId().name( "myID" ) //Entity missing both @DocumentId and @ProvidedId: .property( "title", ElementType.FIELD ).field() .property( "text", ElementType.FIELD ).field() ; SearchConfigurationForTest cfg = new SearchConfigurationForTest() .setProgrammaticMapping( mapping ) .setIdProvidedImplicit( true ) .addClass( Book.class ); storeBooksViaProvidedId( cfg, "myID", false ); }
.property( "owner", ElementType.FIELD ) .field() .property( "street1", ElementType.FIELD ) .field() .field().name( "street1_ngram" ).analyzer( NGRAM_ANALYZER_NAME ) .bridge( ConcatStringBridge.class ).param( ConcatStringBridge.SIZE, "4" ) .field().name( "street1_normalized" ).normalizer( LOWERCASE_NORMALIZER_NAME ) .property( "street2", ElementType.METHOD ) .field().name( "idx_street2" ).store( Store.YES ).boost( 2 ) .entity( ProvidedIdEntry.class ).indexed() .property( "name", ElementType.FIELD ) .field().name( "providedidentry.name" ).analyzer( EN_ANALYZER_NAME ).index( Index.YES ).store( Store.YES ) .property( "blurb", ElementType.FIELD ) .field().name( "providedidentry.blurb" ).analyzer( EN_ANALYZER_NAME ).index( Index.YES ).store( Store.YES ) .property( "age", ElementType.FIELD ) .field().name( "providedidentry.age" ).analyzer( EN_ANALYZER_NAME ).index( Index.YES ).store( Store.YES ) .entity( ProductCatalog.class ).indexed() .property( "name", ElementType.FIELD ) .field().name( "productCatalogName" ).index( Index.YES ).analyzer( EN_ANALYZER_NAME ).store( Store.YES ) .property( "items", ElementType.FIELD ) .indexEmbedded() .includeEmbeddedObjectId( true ) .property( "description", ElementType.FIELD ) .field().name( "description" ).analyzer( EN_ANALYZER_NAME ).index( Index.YES ).store( Store.YES ) .property( "productCatalog", ElementType.FIELD )