Package org.hibernate.search.engine.spi

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


    sendWorkToShards( work, false );
  }

  private void sendWorkToShards(LuceneWork work, boolean forceAsync) {
    final Class<?> entityType = work.getEntityClass();
    EntityIndexBinder entityIndexBinding = searchFactoryImplementor.getIndexBindingForEntity( entityType );
    IndexShardingStrategy shardingStrategy = entityIndexBinding.getSelectionStrategy();
    if ( forceAsync ) {
      work.getWorkDelegate( StreamingSelectionVisitor.INSTANCE )
          .performStreamOperation( work, shardingStrategy, progressMonitor, forceAsync );
    }
    else {
View Full Code Here


  }

  private Collection<IndexManager> uniqueIndexManagerForTypes(Collection<Class<?>> entityTypes) {
    HashMap<String,IndexManager> uniqueBackends = new HashMap<String, IndexManager>( entityTypes.size() );
    for ( Class<?> type : entityTypes ) {
      EntityIndexBinder indexBindingForEntity = searchFactoryImplementor.getIndexBindingForEntity( type );
      if ( indexBindingForEntity != null ) {
        IndexManager[] indexManagers = indexBindingForEntity.getIndexManagers();
        for ( IndexManager im : indexManagers ) {
          uniqueBackends.put( im.getIndexName(), im );
        }
      }
    }
View Full Code Here

      throw log.needAtLeastOneIndexedEntityType();
    }

    HashMap<String, IndexManager> indexManagers = new HashMap<String, IndexManager>();
    for ( Class<?> type : entities ) {
      EntityIndexBinder entityIndexBinding = searchFactory.getSafeIndexBindingForEntity( type );
      IndexManager[] indexManagersForAllShards = entityIndexBinding.getSelectionStrategy()
          .getIndexManagersForAllShards();
      for ( IndexManager im : indexManagersForAllShards ) {
        indexManagers.put( im.getIndexName(), im );
      }
    }
View Full Code Here

  private void assertFacetingFieldExists() {
    if ( fieldName == null ) {
      throw new IllegalArgumentException( "null is an invalid field name" );
    }

    EntityIndexBinder indexBinding = factory.getIndexBindingForEntity( entityType );
    if ( indexBinding == null ) {
      throw new SearchException(
          "Entity " + entityType.getName()
              + " is not an indexed entity. Unable to create faceting request"
      );
    }
    documentBuilder = indexBinding.getDocumentBuilder();
  }
View Full Code Here

  }

  static DocumentBuilderIndexedEntity<?> getDocumentBuilder(QueryBuildingContext queryContext) {
    final SearchFactoryImplementor factory = queryContext.getFactory();
    final Class<?> type = queryContext.getEntityType();
    EntityIndexBinder indexBinding = factory.getIndexBindingForEntity( type );
    if ( indexBinding == null ) {
      throw new AssertionFailure( "Class in not indexed: " + type );
    }
    return indexBinding.getDocumentBuilder();
  }
View Full Code Here

    }
    else {
      Set<Class<?>> involvedClasses = new HashSet<Class<?>>( indexedTargetedEntities.size() );
      involvedClasses.addAll( indexedTargetedEntities );
      for ( Class<?> clazz : indexedTargetedEntities ) {
        EntityIndexBinder indexBinder = builders.get( clazz );
        if ( indexBinder != null ) {
          DocumentBuilderIndexedEntity<?> builder = indexBinder.getDocumentBuilder();
          involvedClasses.addAll( builder.getMappedSubclasses() );
        }
      }

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

    Map<Class<?>, EntityIndexBinder> builders = searchFactoryImplementor.getIndexBindingForEntity();
    Set<FieldCacheCollectorFactory> allCollectors = new HashSet<FieldCacheCollectorFactory>();
    // we need all documentBuilder to agree on type, fieldName, and enabling the option:
    FieldCacheCollectorFactory anyImplementation = null;
    for ( Class<?> clazz : classesAndSubclasses ) {
      EntityIndexBinder docBuilder = builders.get( clazz );
      FieldCacheCollectorFactory fieldCacheCollectionFactory = docBuilder.getIdFieldCacheCollectionFactory();
      if ( fieldCacheCollectionFactory == null ) {
        // some implementation disable it, so we won't use it
        return null;
      }
      anyImplementation = fieldCacheCollectionFactory;
View Full Code Here

      im.optimize();
    }
  }

  public void optimize(Class entityType) {
    EntityIndexBinder entityIndexBinding = getSafeIndexBindingForEntity( entityType );
    for ( IndexManager im: entityIndexBinding.getIndexManagers() ) {
      im.optimize();
    }
  }
View Full Code Here

    }
    return analyzer;
  }

  public Analyzer getAnalyzer(Class<?> clazz) {
    EntityIndexBinder entityIndexBinding = getSafeIndexBindingForEntity( clazz );
    DocumentBuilderIndexedEntity<?> builder = entityIndexBinding.getDocumentBuilder();
    return builder.getAnalyzer();
  }
View Full Code Here

  public EntityIndexBinder getSafeIndexBindingForEntity(Class<?> entityType) {
    if ( entityType == null ) {
      throw log.nullIsInvalidIndexedType();
    }
    EntityIndexBinder entityIndexBinding = getIndexBindingForEntity( entityType );
    if ( entityIndexBinding == null ) {
      throw log.notAnIndexedType( entityType.getName() );
    }
    return entityIndexBinding;
  }
View Full Code Here

TOP

Related Classes of org.hibernate.search.engine.spi.EntityIndexBinder

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.