public IndexedMapping indexed() { return new IndexedMapping( mapping, entity ); }
public AnalyzerDefMapping analyzerDef(String name, Class<? extends TokenizerFactory> tokenizerFactory) { return analyzerDef( name, "", tokenizerFactory ); }
@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 ); }
.boost( 2 ) .classBridge( AddressClassBridge.class ) .analyzer( ENGLISH_ANALYZER_NAME ) .property( "addressId", ElementType.FIELD ).documentId().name( "id" ) .field().name( "idx_street2" ).store( Store.YES ).boost( 2 ) .entity( ProvidedIdEntry.class ).indexed() .providedId().name( "providedidentry.providedid" ).bridge( LongBridge.class ) .property( "name", ElementType.FIELD ) .field().name( "providedidentry.name" ).analyzer( EN_ANALYZER_NAME ).index( Index.YES ).store( Store.YES ) .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" ) .property( "name", ElementType.FIELD ) .field().name( "productCatalogName" ).index( Index.YES ).analyzer( EN_ANALYZER_NAME ).store( Store.YES ) .entity( Item.class ) .indexed() .property( "id", ElementType.FIELD ) .documentId() .sortableField() .dynamicBoost( CustomBoostStrategy.class ) .indexed() .property( "libraryId", ElementType.FIELD ) .documentId().name( "id" ) .property( "name", ElementType.FIELD )
static SearchMapping buildMappingDefinition() { SearchMapping mapping = new SearchMapping(); mapping .entity( TelephoneRecord.class ) .indexed() .indexName( "phoneNumbersIndex" ) .property( "id", ElementType.FIELD ).documentId() .property( "phone", ElementType.FIELD ).field().analyze( Analyze.NO ).store( Store.YES ) .entity( AddressBook.class ) .indexed() .indexName( "addressBookIndex" ) .property( "id", ElementType.FIELD ).documentId() .property( "name", ElementType.FIELD ).field().store( Store.YES ) ; return mapping; }
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(); }
@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 ); }
@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); } }
.entity(InternalProcessDefinition.class).indexed().indexName("process_definition") .property("dbid", ElementType.FIELD).documentId().name(ProcessDefinitionIndex.DBID) .entity(LightProcessDefinitionImpl.class) .entity(InternalProcessInstance.class).indexed().indexName("process_instance") .property("dbid", ElementType.FIELD).documentId().name(ProcessInstanceIndex.DBID) .entity(ProcessInstanceImpl.class) .entity(CommentImpl.class).indexed().indexName("comment") .property("dbid", ElementType.FIELD).documentId().name(CommentIndex.DBID) .entity(Comment.class) .entity(InternalActivityInstance.class).indexed().indexName("activity_instance") .property("dbid", ElementType.FIELD).documentId().name(ActivityInstanceIndex.DBID) .entity(TaskInstance.class) .entity(UserImpl.class).indexed().indexName("user") .property("dbid", ElementType.FIELD).documentId().name(UserIndex.DBID) .property("username", ElementType.FIELD).field().name(UserIndex.NAME) .entity(RoleImpl.class).indexed().indexName("role") .property("dbid", ElementType.FIELD).documentId().name(RoleIndex.DBID) .property("name", ElementType.FIELD).field().name(RoleIndex.NAME) .property("label", ElementType.FIELD).field().name(RoleIndex.LABEL) .entity(GroupImpl.class).indexed().indexName("group") .property("dbid", ElementType.FIELD).documentId().name(GroupIndex.DBID) .property("name", ElementType.METHOD).field().name(GroupIndex.NAME) .property("label", ElementType.METHOD).field().name(GroupIndex.LABEL)
@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 ); }
protected MutableSearchFactory getMutableSearchFactoryWithSingleEntity(SearchConfigurationForTest cfg) { SearchMapping mapping = new SearchMapping(); mapping .entity( Document.class ).indexed().indexName( "index1" ) .property( "id", ElementType.FIELD ).documentId() .property( "title", ElementType.FIELD ).field() ; cfg.setProgrammaticMapping( mapping ); cfg.addClass( Document.class ); return (MutableSearchFactory) integratorResource.create( cfg ); }
@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 ); }
@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() ) ); }
private void verifyIndexManagerTypeIs(Class<? extends IndexManager> expectedIndexManagerClass, SearchConfigurationForTest cfg) { SearchMapping mapping = new SearchMapping(); mapping .entity( Document.class ).indexed().indexName( "documents" ) .property( "id", ElementType.FIELD ).documentId() .property( "title", ElementType.FIELD ).field(); cfg.setProgrammaticMapping( mapping ); cfg.addClass( Document.class ); SearchIntegrator sf = integratorResource.create( cfg ); Assert.assertEquals( expectedIndexManagerClass, extractDocumentIndexManagerClassName( sf, "documents" ) ); // trigger a SearchFactory rebuild: sf.addClasses( Dvd.class ); // and verify the option is not lost: Assert.assertEquals( expectedIndexManagerClass, extractDocumentIndexManagerClassName( sf, "dvds" ) ); Assert.assertEquals( expectedIndexManagerClass, extractDocumentIndexManagerClassName( sf, "documents" ) ); }
public IndexedMapping indexed() { return new IndexedMapping( mapping, entity ); }
@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 ); }
public AnalyzerDefMapping analyzerDef(String name, Class<? extends TokenizerFactory> tokenizerFactory) { return analyzerDef( name, "", tokenizerFactory ); }
final SearchMapping mapping = new SearchMapping(); mapping.entity(BondPVO.class).indexed() .property("id", ElementType.METHOD).field() .property("name", ElementType.METHOD).field() .property("isin", ElementType.METHOD).field();
public IndexedMapping indexed() { return new IndexedMapping( mapping, entity ); }
@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() ); }