Package org.hibernate.search.engine.spi

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


      // Create all DocumentBuilderIndexedEntity
      // FIXME DocumentBuilderIndexedEntity needs to be built by a helper method receiving Class<T> to infer T properly
      // XClass unfortunately is not (yet) genericized: TODO ?
      TypeMetadata typeMetadata = metadataProvider.getTypeMetadataFor( mappedClass );
      final DocumentBuilderIndexedEntity documentBuilder =
          new DocumentBuilderIndexedEntity(
              mappedXClass,
              typeMetadata,
              configContext,
              searchConfiguration.getReflectionManager(),
              optimizationBlackListedTypes,
View Full Code Here


            "There are no mapped entities. Don't forget to add @Indexed to at least one class."
        );
      }

      for ( EntityIndexBinding entityIndexBinding : builders.values() ) {
        DocumentBuilderIndexedEntity builder = entityIndexBinding.getDocumentBuilder();
        searcherSimilarity = checkSimilarity( searcherSimilarity, entityIndexBinding.getSimilarity() );
        if ( builder.getIdKeywordName() != null ) {
          idFieldNames.add( builder.getIdKeywordName() );
          allowFieldSelectionInProjection = allowFieldSelectionInProjection && builder.allowFieldSelectionInProjection();
        }
        useFieldCacheOnClassTypes = useFieldCacheOnClassTypes || builder.getFieldCacheOption()
            .contains( FieldCacheType.CLASS );
        populateIndexManagers( targetedIndexes, entityIndexBinding.getSelectionStrategy() );
      }
      classesAndSubclasses = null;
    }
    else {
      Set<Class<?>> involvedClasses = new HashSet<Class<?>>( indexedTargetedEntities.size() );
      involvedClasses.addAll( indexedTargetedEntities );
      for ( Class<?> clazz : indexedTargetedEntities ) {
        EntityIndexBinding indexBinder = builders.get( clazz );
        if ( indexBinder != null ) {
          DocumentBuilderIndexedEntity builder = indexBinder.getDocumentBuilder();
          involvedClasses.addAll( builder.getMappedSubclasses() );
        }
      }

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

  private String objectIdInString(Class<?> entityClass, Serializable id, ConversionContext conversionContext) {
    EntityIndexBinding indexBindingForEntity = searchFactory.getIndexBinding( entityClass );
    if ( indexBindingForEntity == null ) {
      throw new SearchException( "Unable to find entity type metadata while deserializing: " + entityClass );
    }
    DocumentBuilderIndexedEntity documentBuilder = indexBindingForEntity.getDocumentBuilder();
    return documentBuilder.objectToString( documentBuilder.getIdKeywordName(), id, conversionContext );
  }
View Full Code Here

   
      // Create all DocumentBuilderIndexedEntity
      //FIXME DocumentBuilderIndexedEntity needs to be built by a helper method receiving Class<T> to infer T properly
      //XClass unfortunately is not (yet) genericized: TODO?
      final DocumentBuilderIndexedEntity<?> documentBuilder =
          new DocumentBuilderIndexedEntity(
              mappedXClass,
              context,
              mappedEntity.getSimilarity(),
              reflectionManager,
              optimizationBlackListedTypes,
View Full Code Here

  private String objectIdInString(Class<?> entityClass, Serializable id, ConversionContext conversionContext) {
    EntityIndexBinding indexBindingForEntity = searchFactory.getIndexBinding( entityClass );
    if ( indexBindingForEntity == null ) {
      throw new SearchException( "Unable to find entity type metadata while deserializing: " + entityClass );
    }
    DocumentBuilderIndexedEntity documentBuilder = indexBindingForEntity.getDocumentBuilder();
    return documentBuilder.objectToString( documentBuilder.getIdKeywordName(), id, conversionContext );
  }
View Full Code Here

      // Create all DocumentBuilderIndexedEntity
      // FIXME DocumentBuilderIndexedEntity needs to be built by a helper method receiving Class<T> to infer T properly
      // XClass unfortunately is not (yet) genericized: TODO ?
      TypeMetadata typeMetadata = metadataProvider.getTypeMetadataFor( mappedClass);
      final DocumentBuilderIndexedEntity<?> documentBuilder =
          new DocumentBuilderIndexedEntity(
              mappedXClass,
              typeMetadata,
              context,
              cfg.getReflectionManager(),
              optimizationBlackListedTypes,
View Full Code Here

  public Query createQuery() {
    return queryCustomizer.setWrappedQuery( createSpatialQuery() ).createQuery();
  }

  private Query createSpatialQuery() {
    final DocumentBuilderIndexedEntity documentBuilder = Helper.getDocumentBuilder( queryContext );
    //FIXME that will have to change probably but today, if someone uses latitude / longitude
    //      we use boolean style spatial queries
    //      and on coordinates field, use spatial hash query
    // FIXME in the future we will likely react to some state stored in SpatialFieldBridge (for the indexing strategy)
    String coordinatesField = spatialContext.getCoordinatesField();
    FieldBridge fieldBridge = documentBuilder.getBridge( coordinatesField );
    if ( fieldBridge instanceof SpatialFieldBridgeByHash ) {
      return SpatialQueryBuilderFromCoordinates.buildSpatialQueryByHash(
          spatialContext.getCoordinates(),
          spatialContext.getRadiusDistance(), // always in KM so far, no need to convert
          coordinatesField );
View Full Code Here

    }
  }

  private Query createQuery(FieldContext fieldContext, ConversionContext conversionContext) {
    final Query perFieldQuery;
    final DocumentBuilderIndexedEntity documentBuilder = Helper.getDocumentBuilder( queryContext );
    final FieldBridge fieldBridge = fieldContext.getFieldBridge() != null ? fieldContext.getFieldBridge() : documentBuilder.getBridge( fieldContext.getField() );
    if ( fieldBridge instanceof NumericFieldBridge ) {
      return NumericFieldUtils.createExactMatchQuery( fieldContext.getField(), value );
    }

    final String searchTerm = buildSearchTerm( fieldContext, documentBuilder, conversionContext );
View Full Code Here

  }

  @Override
  public void performWork(LuceneWork work, IndexWriter writer, IndexingMonitor monitor) {
    final Class<?> entityType = work.getEntityClass();
    DocumentBuilderIndexedEntity documentBuilder = workspace.getDocumentBuilder( entityType );
    Map<String, String> fieldToAnalyzerMap = work.getFieldToAnalyzerMap();
    ScopedAnalyzer analyzer = documentBuilder.getAnalyzer();
    analyzer = updateAnalyzerMappings( workspace, analyzer, fieldToAnalyzerMap );
    if ( log.isTraceEnabled() ) {
      log.trace( "add to Lucene index: " + entityType + "#" + work.getId() + ":" + work.getDocument() );
    }
    try {
View Full Code Here

  }

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

TOP

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

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.