Examples of DocumentBuilderIndexedEntity


Examples of org.hibernate.search.engine.DocumentBuilderIndexedEntity

          involvedClasses.addAll( builder.getMappedSubclasses() );
        }
      }

      for ( Class clazz : involvedClasses ) {
        DocumentBuilderIndexedEntity builder = builders.get( clazz );
        //TODO should we rather choose a polymorphic path and allow non mapped entities
        if ( builder == null ) {
          throw new SearchException( "Not a mapped entity (don't forget to add @Indexed): " + clazz );
        }
        if ( builder.getIdKeywordName() != null ) {
          idFieldNames.add( builder.getIdKeywordName() );
          allowFieldSelectionInProjection = allowFieldSelectionInProjection && builder.allowFieldSelectionInProjection();
        }
        searcherSimilarity = checkSimilarity( searcherSimilarity, builder );
        useFieldCacheOnClassTypes = useFieldCacheOnClassTypes || builder.getFieldCacheOption()
            .contains( FieldCacheType.CLASS );
        populateDirectories( targetedDirectories, builder );
      }
      this.classesAndSubclasses = involvedClasses;
    }
View Full Code Here

Examples of org.hibernate.search.engine.DocumentBuilderIndexedEntity

   */
  @SuppressWarnings( "unchecked" )
  public void testAddWorkGetReplacedByDeleteWork() throws Exception {
    FullTextSession fullTextSession = org.hibernate.search.Search.getFullTextSession( openSession() );
    SearchFactoryImpl searchFactory = ( SearchFactoryImpl ) fullTextSession.getSearchFactory();
    DocumentBuilderIndexedEntity builder = searchFactory.getDocumentBuilderIndexedEntity( SpecialPerson.class );

    // create test entity
    SpecialPerson person = new SpecialPerson();
    person.setName( "Joe Smith" );

    EmailAddress emailAddress = new EmailAddress();
    emailAddress.setAddress( "foo@foobar.com" );
    emailAddress.setDefaultAddress(true);

    person.addEmailAddress( emailAddress );

    List<LuceneWork> queue = new ArrayList<LuceneWork>();

    builder.addWorkToQueue( SpecialPerson.class, person, 1, WorkType.ADD, queue, searchFactory );

    assertEquals("There should only be one job in the queue", 1, queue.size());
    assertTrue("Wrong job type", queue.get(0) instanceof AddLuceneWork );

    builder.addWorkToQueue( SpecialPerson.class, person, 1, WorkType.DELETE, queue, searchFactory );

    assertEquals("There should only be one job in the queue", 1, queue.size());
    assertTrue("Wrong job type. Add job should have been replaced by delete.", queue.get(0) instanceof DeleteLuceneWork );

    fullTextSession.close();
View Full Code Here

Examples of org.hibernate.search.engine.DocumentBuilderIndexedEntity

          involvedClasses.addAll( builder.getMappedSubclasses() );
        }
      }

      for ( Class clazz : involvedClasses ) {
        DocumentBuilderIndexedEntity builder = builders.get( clazz );
        //TODO should we rather choose a polymorphic path and allow non mapped entities
        if ( builder == null ) {
          throw new HibernateException( "Not a mapped entity (don't forget to add @Indexed): " + clazz );
        }
        if ( builder.getIdKeywordName() != null ) {
          idFieldNames.add( builder.getIdKeywordName() );
          allowFieldSelectionInProjection = allowFieldSelectionInProjection && builder.allowFieldSelectionInProjection();
        }
        searcherSimilarity = checkSimilarity( searcherSimilarity, builder );
        populateDirectories( targetedDirectories, builder );
      }
      this.classesAndSubclasses = involvedClasses;
View Full Code Here

Examples of org.hibernate.search.engine.DocumentBuilderIndexedEntity

          involvedClasses.addAll( builder.getMappedSubclasses() );
        }
      }

      for ( Class clazz : involvedClasses ) {
        DocumentBuilderIndexedEntity builder = builders.get( clazz );
        //TODO should we rather choose a polymorphic path and allow non mapped entities
        if ( builder == null ) {
          throw new HibernateException( "Not a mapped entity (don't forget to add @Indexed): " + clazz );
        }
        if ( builder.getIdKeywordName() != null ) {
          idFieldNames.add( builder.getIdKeywordName() );
          allowFieldSelectionInProjection = allowFieldSelectionInProjection && builder.allowFieldSelectionInProjection();
        }
        searcherSimilarity = checkSimilarity( searcherSimilarity, builder );
        populateDirectories( targetedDirectories, builder );
      }
      this.classesAndSubclasses = involvedClasses;
View Full Code Here

Examples of org.hibernate.search.engine.DocumentBuilderIndexedEntity

          involvedClasses.addAll( builder.getMappedSubclasses() );
        }
      }

      for ( Class clazz : involvedClasses ) {
        DocumentBuilderIndexedEntity builder = builders.get( clazz );
        //TODO should we rather choose a polymorphic path and allow non mapped entities
        if ( builder == null ) {
          throw new HibernateException( "Not a mapped entity (don't forget to add @Indexed): " + clazz );
        }
        if ( builder.getIdKeywordName() != null ) {
          idFieldNames.add( builder.getIdKeywordName() );
          allowFieldSelectionInProjection = allowFieldSelectionInProjection && builder.allowFieldSelectionInProjection();
        }
        final DirectoryProvider[] directoryProviders = builder.getDirectoryProviderSelectionStrategy()
            .getDirectoryProvidersForAllShards();
        searcherSimilarity = checkSimilarity( searcherSimilarity, builder );
        populateDirectories( directories, directoryProviders );
      }
      this.classesAndSubclasses = involvedClasses;
View Full Code Here

Examples of org.hibernate.search.engine.DocumentBuilderIndexedEntity

  public IndexInteractionType getIndexInteractionType() {
    return IndexInteractionType.NEEDS_INDEXWRITER;
  }

  public void performWork(LuceneWork work, IndexWriter writer) {
    @SuppressWarnings("unchecked")
    DocumentBuilderIndexedEntity documentBuilder = workspace.getDocumentBuilder( work.getEntityClass() );
    Map<String, String> fieldToAnalyzerMap = ( ( AddLuceneWork ) work ).getFieldToAnalyzerMap();
    ScopedAnalyzer analyzer = ( ScopedAnalyzer ) documentBuilder.getAnalyzer();
    analyzer = updateAnalyzerMappings( analyzer, fieldToAnalyzerMap, workspace );
    Similarity similarity = documentBuilder.getSimilarity();
    if ( log.isTraceEnabled() ) {
      log.trace(
          "add to Lucene index: {}#{}:{}",
          new Object[] { work.getEntityClass(), work.getId(), work.getDocument() }
      );
View Full Code Here

Examples of org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity

  }

  @SuppressWarnings({ "unchecked", "rawtypes" })
  private AddLuceneWork createAddLuceneWork(Object entity, InstanceInitializer sessionInitializer,
      ConversionContext conversionContext, Serializable id, Class<?> clazz, EntityIndexBinder entityIndexBinding) {
    DocumentBuilderIndexedEntity docBuilder = entityIndexBinding.getDocumentBuilder();
    String idInString = idInString( conversionContext, id, clazz, docBuilder );
    // depending on the complexity of the object graph going to be indexed it's possible
    // that we hit the database several times during work construction.
    return docBuilder.createAddWork( clazz, entity, id, idInString, sessionInitializer, conversionContext );
  }
View Full Code Here

Examples of org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity

  }

  @SuppressWarnings({ "unchecked", "rawtypes" })
  private AddLuceneWork createAddLuceneWork(Object entity, InstanceInitializer sessionInitializer,
      ConversionContext conversionContext, Serializable id, Class<?> clazz, EntityIndexBinder entityIndexBinding) {
    DocumentBuilderIndexedEntity docBuilder = entityIndexBinding.getDocumentBuilder();
    String idInString = idInString( conversionContext, id, clazz, docBuilder );
    // depending on the complexity of the object graph going to be indexed it's possible
    // that we hit the database several times during work construction.
    return docBuilder.createAddWork( clazz, entity, id, idInString, sessionInitializer, conversionContext );
  }
View Full Code Here

Examples of org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity

          return;
      }
      //default: continue indexing this instance
    }

    DocumentBuilderIndexedEntity docBuilder = entityIndexBinding.getDocumentBuilder();
    TwoWayFieldBridge idBridge = docBuilder.getIdBridge();
    conversionContext.pushProperty( docBuilder.getIdKeywordName() );
    String idInString = null;
    try {
      idInString = conversionContext
          .setClass( clazz )
          .twoWayConversionContext( idBridge )
          .objectToString( id );
    }
    finally {
      conversionContext.popProperty();
    }
    //depending on the complexity of the object graph going to be indexed it's possible
    //that we hit the database several times during work construction.
    AddLuceneWork addWork = docBuilder.createAddWork(
        clazz,
        entity,
        id,
        idInString,
        sessionInitializer,
View Full Code Here

Examples of org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity

      // it might be possible to receive not-indexes subclasses of the currently indexed type;
      // being not-indexed, we skip them.
      // FIXME for improved performance: avoid loading them in an early phase.
      return;
    }
    DocumentBuilderIndexedEntity docBuilder = entityIndexBinding.getDocumentBuilder();
    TwoWayFieldBridge idBridge = docBuilder.getIdBridge();
    ContextualException2WayBridge contextualBridge = new ContextualException2WayBridge()
        .setClass(clazz)
        .setFieldName(docBuilder.getIdKeywordName())
        .setFieldBridge(idBridge);
    String idInString = contextualBridge.objectToString( id );
    //depending on the complexity of the object graph going to be indexed it's possible
    //that we hit the database several times during work construction.
    AddLuceneWork addWork = docBuilder.createAddWork( clazz, entity, id, idInString, sessionInitializer );
    backend.enqueueAsyncWork( addWork );
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.