Package org.hibernate.search.backend

Examples of org.hibernate.search.backend.AddLuceneWork


    doc.add( field );
    field = new Field( "id", "1", Field.Store.YES, Field.Index.NOT_ANALYZED );
    doc.add( field );
    field = new Field( "logo", shirt.getLogo(), Field.Store.NO, Field.Index.ANALYZED );
    doc.add( field );
    LuceneWork luceneWork = new AddLuceneWork(
        shirt.getId(), String.valueOf( shirt.getId() ), shirt.getClass(), doc
    );
    List<LuceneWork> queue = new ArrayList<LuceneWork>();
    queue.add( luceneWork );
    return queue;
View Full Code Here


  }

  private AddLuceneWork createAddWork(Class<T> entityClass, T entity, Serializable id, String idInString, boolean isBatch) {
    Map<String, String> fieldToAnalyzerMap = new HashMap<String, String>();
    Document doc = getDocument( entity, id, fieldToAnalyzerMap );
    AddLuceneWork addWork;
    if ( fieldToAnalyzerMap.isEmpty() ) {
      addWork = new AddLuceneWork( id, idInString, entityClass, doc, isBatch );
    }
    else {
      addWork = new AddLuceneWork( id, idInString, entityClass, doc, fieldToAnalyzerMap, isBatch );
    }
    return addWork;
  }
View Full Code Here

    // FIXME for improved performance: avoid loading them in an early phase.
    if ( entityIndexBinding != null ) {
      EntityIndexingInterceptor interceptor = entityIndexBinding.getEntityIndexingInterceptor();
      if ( isNotSkippable( interceptor, entity ) ) {
        Serializable id = session.getIdentifier( entity );
        AddLuceneWork addWork = createAddLuceneWork( entity, sessionInitializer, conversionContext, id, clazz,
            entityIndexBinding );
        backend.enqueueAsyncWork( addWork );
      }
    }
  }
View Full Code Here

    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

    Class<?> entityClass = ClassLoaderHelper.classForName(
        entityClassName,
        LuceneWorkHydrator.class.getClassLoader(),
        "entity class"
    );
    LuceneWork result = new AddLuceneWork(
        id,
        objectIdInString( entityClass, id, conversionContext ),
        entityClass,
        getLuceneDocument(),
        fieldToAnalyzerMap
View Full Code Here

  }

  public AddLuceneWork createAddWork(Class<T> entityClass, T entity, Serializable id, String idInString, InstanceInitializer sessionInitializer, ConversionContext conversionContext) {
    Map<String, String> fieldToAnalyzerMap = new HashMap<String, String>();
    Document doc = getDocument( entity, id, fieldToAnalyzerMap, sessionInitializer, conversionContext );
    final AddLuceneWork addWork;
    if ( fieldToAnalyzerMap.isEmpty() ) {
      addWork = new AddLuceneWork( id, idInString, entityClass, doc );
    }
    else {
      addWork = new AddLuceneWork( id, idInString, entityClass, doc, fieldToAnalyzerMap );
    }
    return addWork;
  }
View Full Code Here

  }

  public AddLuceneWork createAddWork(Class<T> entityClass, T entity, Serializable id, String idInString, InstanceInitializer sessionInitializer, ConversionContext conversionContext) {
    Map<String, String> fieldToAnalyzerMap = new HashMap<String, String>();
    Document doc = getDocument( entity, id, fieldToAnalyzerMap, sessionInitializer, conversionContext, null );
    final AddLuceneWork addWork;
    if ( fieldToAnalyzerMap.isEmpty() ) {
      addWork = new AddLuceneWork( id, idInString, entityClass, doc );
    }
    else {
      addWork = new AddLuceneWork( id, idInString, entityClass, doc, fieldToAnalyzerMap );
    }
    return addWork;
  }
View Full Code Here

    Class<?> entityClass = ClassLoaderHelper.classForName(
        entityClassName,
        "entity class",
        searchFactory.getServiceManager()
    );
    LuceneWork result = new AddLuceneWork(
        id,
        objectIdInString( entityClass, id, conversionContext ),
        entityClass,
        getLuceneDocument(),
        fieldToAnalyzerMap
View Full Code Here

    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

    }
    boolean searchForContainers = false;
    String idInString = idBridge.objectToString( id );
    if ( workType == WorkType.ADD ) {
      Document doc = getDocument( entity, id );
      queue.add( new AddLuceneWork( id, idInString, entityClass, doc ) );
      searchForContainers = true;
    }
    else if ( workType == WorkType.DELETE || workType == WorkType.PURGE ) {
      queue.add( new DeleteLuceneWork( id, idInString, entityClass ) );
    }
    else if ( workType == WorkType.PURGE_ALL ) {
      queue.add( new PurgeAllLuceneWork( entityClass ) );
    }
    else if ( workType == WorkType.UPDATE || workType == WorkType.COLLECTION ) {
      Document doc = getDocument( entity, id );
      /**
       * even with Lucene 2.1, use of indexWriter to update is not an option
       * We can only delete by term, and the index doesn't have a term that
       * uniquely identify the entry.
       * But essentially the optimization we are doing is the same Lucene is doing, the only extra cost is the
       * double file opening.
       */
      queue.add( new DeleteLuceneWork( id, idInString, entityClass ) );
      queue.add( new AddLuceneWork( id, idInString, entityClass, doc ) );
      searchForContainers = true;
    }
    else if ( workType == WorkType.INDEX ) {
      Document doc = getDocument( entity, id );
      queue.add( new DeleteLuceneWork( id, idInString, entityClass ) );
      LuceneWork work = new AddLuceneWork( id, idInString, entityClass, doc );
      work.setBatch( true );
      queue.add( work );
      searchForContainers = true;
    }

    else {
View Full Code Here

TOP

Related Classes of org.hibernate.search.backend.AddLuceneWork

Copyright © 2018 www.massapicom. 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.