public IndexEmbeddedMapping indexEmbedded() { return new IndexEmbeddedMapping( mapping, property, entity ); }
public AnalyzerDefMapping analyzerDef(String name, Class<? extends TokenizerFactory> tokenizerFactory) { return analyzerDef( name, "", tokenizerFactory ); }
public IndexEmbeddedMapping includePaths(String firstPath, String... furtherPaths) { this.indexEmbedded.put( "includePaths", merge( firstPath, furtherPaths ) ); return this; }
.property( "country", ElementType.METHOD ) .indexEmbedded() .includePaths( "id", "name" ) .entity( Country.class ) .indexed() .property( "name", ElementType.METHOD )
.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) .property("dbid", ElementType.FIELD).documentId().name(CommentIndex.DBID) .entity(Comment.class) .property("message", ElementType.METHOD).field().name(CommentIndex.MESSAGE) .property("userId", ElementType.METHOD).field().name(CommentIndex.AUTHOR) .property("date", ElementType.METHOD).field().name(CommentIndex.DATE) .property("dbid", ElementType.FIELD).documentId().name(RoleIndex.DBID) .property("name", ElementType.FIELD).field().name(RoleIndex.NAME) .property("label", ElementType.FIELD).field().name(RoleIndex.LABEL)
.property( "items", ElementType.FIELD ) .indexEmbedded() .includeEmbeddedObjectId( true ) .entity( Item.class ) .indexed() .property( "id", ElementType.FIELD )
@Test public void canSetIncludeEmbeddedObjectIdProgrammatically() throws Exception { try ( FullTextSessionBuilder builder = getFullTextSessionBuilder() ) { // given builder.fluentMapping() .entity( Address.class ) .indexed() .property( "addressId", ElementType.METHOD ) .documentId() .name( "id" ) .property( "country", ElementType.METHOD ) .indexEmbedded() .includeEmbeddedObjectId( true ); Long scotlandCountryId = setupTestData( builder ); FullTextSession s = builder.openFullTextSession(); // when QueryParser parser = new QueryParser( "id", TestConstants.standardAnalyzer ); org.apache.lucene.search.Query luceneQuery = parser.parse( "country.id:" + scotlandCountryId ); Transaction tx = s.beginTransaction(); // then FullTextQuery query = s.createFullTextQuery( luceneQuery ); assertEquals( 1, query.getResultSize() ); assertEquals( "Bob McRobb", ( (Address) query.list().iterator().next() ).getOwner() ); tx.commit(); s.close(); } }
@Test public void canSetIndexNullAsProgrammatically() throws Exception { try ( FullTextSessionBuilder builder = getFullTextSessionBuilder() ) { // given builder.fluentMapping() .entity( Address.class ) .indexed() .property( "addressId", ElementType.METHOD ) .documentId() .name( "id" ) .property( "country", ElementType.METHOD ) .indexEmbedded() .indexNullAs( IndexedEmbedded.DEFAULT_NULL_TOKEN ); setupTestData( builder ); FullTextSession s = builder.openFullTextSession(); // when QueryParser parser = new QueryParser( "id", TestConstants.standardAnalyzer ); org.apache.lucene.search.Query luceneQuery = parser.parse( "country:" + "_null_" ); Transaction tx = s.beginTransaction(); // then FullTextQuery query = s.createFullTextQuery( luceneQuery ); assertEquals( 1, query.getResultSize() ); assertEquals( "Alice Donellis", ( (Address) query.list().iterator().next() ).getOwner() ); tx.commit(); s.close(); } }
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(); }
public AnalyzerDefMapping analyzerDef(String name, Class<? extends TokenizerFactory> tokenizerFactory) { return analyzerDef( name, "", tokenizerFactory ); }
public IndexEmbeddedMapping includePaths(String firstPath, String... furtherPaths) { this.indexEmbedded.put( "includePaths", merge( firstPath, furtherPaths ) ); return this; }
public IndexEmbeddedMapping indexEmbedded() { return new IndexEmbeddedMapping( mapping, property, entity ); }