Package org.hibernate.search.engine

Examples of org.hibernate.search.engine.DocumentBuilder$PropertiesMetadata


    workspace = new Workspace( searchFactoryImplementor );
    worker = new LuceneWorker( workspace );
    try {
      List<LuceneWorker.WorkWithPayload> queueWithFlatDPs = new ArrayList<LuceneWorker.WorkWithPayload>( queue.size()*2 );
      for ( LuceneWork work : queue ) {
        DocumentBuilder documentBuilder = searchFactoryImplementor.getDocumentBuilders().get( work.getEntityClass() );
        IndexShardingStrategy shardingStrategy = documentBuilder.getDirectoryProviderSelectionStrategy();

        if ( PurgeAllLuceneWork.class.isAssignableFrom( work.getClass() ) ) {
          /***********hibernate search code**********
          DirectoryProvider[] providers = shardingStrategy.getDirectoryProvidersForDeletion(
              work.getEntityClass(),
View Full Code Here


    }
    else {
      Set<Class> involvedClasses = new HashSet<Class>( classes.length );
      Collections.addAll( involvedClasses, classes );
      for (Class clazz : classes) {
        DocumentBuilder builder = builders.get( clazz );
        if ( builder != null ) involvedClasses.addAll( builder.getMappedSubclasses() );
      }
      for (Class clazz : involvedClasses) {
        DocumentBuilder 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 );

//        final DirectoryProvider[] directoryProviders =
//            builder.getDirectoryProviderSelectionStrategy().getDirectoryProvidersForAllShards();
       
        //changed by jerry
        final DirectoryProvider[] directoryProviders =
          builder.getDirectoryProviderSelectionStrategy().getDirectoryProvidersForSearch(clazz,luceneQuery);

        for (DirectoryProvider provider : directoryProviders) {
          if ( !directories.contains( provider ) ) {
            directories.add( provider );
          }
View Full Code Here

        if ( mappedXClass != null) {
          if ( mappedXClass.isAnnotationPresent( Indexed.class ) ) {
            DirectoryProviderFactory.DirectoryProviders providers = factory.createDirectoryProviders( mappedXClass, cfg, this, reflectionManager );
            //FIXME DocumentBuilder needs to be built by a helper method receiving Class<T> to infer T properly
            //XClass unfortunately is not (yet) genericized: TODO?
            final DocumentBuilder<?> documentBuilder = new DocumentBuilder(
                mappedXClass, context, providers.getProviders(), providers.getSelectionStrategy(),
                reflectionManager
            );

            documentBuilders.put( mappedClass, documentBuilder );
          }
          else {
            //FIXME DocumentBuilder needs to be built by a helper method receiving Class<T> to infer T properly
            //XClass unfortunately is not (yet) genericized: TODO?
            final DocumentBuilder<?> documentBuilder = new DocumentBuilder(
                mappedXClass, context, reflectionManager
            );
            //TODO enhance that, I don't like to expose EntityState
            if ( documentBuilder.getEntityState() != EntityState.NON_INDEXABLE ) {
              containedInOnlyBuilders.put( mappedClass, documentBuilder );
            }
          }
          bindFilterDefs(mappedXClass);
          //TODO should analyzer def for classes at tyher sqme level???
View Full Code Here

    }

    // accessing the document builders is not strictly necessary but a small optimization plus let's make sure the
    // client didn't mess something up.
    SearchFactoryImplementor searchFactoryImplementor = getSearchFactoryImplementor();
    DocumentBuilder builder = searchFactoryImplementor.getDocumentBuilder( entityType );
    if ( builder == null ) {
      String msg = "Entity to index is not an @Indexed entity: " + entityType.getName();
      throw new IllegalArgumentException( msg );
    }

    Work<T> work;
    if ( id == null ) {
      // purge the main entity
      work = new Work<T>( entityType, id, WorkType.PURGE_ALL );
      searchFactoryImplementor.getWorker().performWork( work, transactionContext );

      // purge the subclasses
      Set<Class<?>> subClasses = builder.getMappedSubclasses();
      for ( Class clazz : subClasses ) {
        @SuppressWarnings( "unchecked" )
        Work subClassWork = new Work( clazz, id, WorkType.PURGE_ALL );
        searchFactoryImplementor.getWorker().performWork( subClassWork, transactionContext );
      }
View Full Code Here

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

      for ( Class clazz : involvedClasses ) {
        DocumentBuilder 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

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

  public void performWork(LuceneWork work, IndexWriter writer) {
    DocumentBuilder documentBuilder = workspace.getDocumentBuilder( work.getEntityClass() );
    Analyzer analyzer = documentBuilder.getAnalyzer();
    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

    }

    // accessing the document builders is not strictly necessary but a small optimization plus let's make sure the
    // client didn't mess something up.
    SearchFactoryImplementor searchFactoryImplementor = getSearchFactoryImplementor();
    DocumentBuilder builder = searchFactoryImplementor.getDocumentBuilder( entityType );
    if ( builder == null ) {
      String msg = "Entity to index is not an @Indexed entity: " + entityType.getName();
      throw new IllegalArgumentException( msg );
    }

    Work work;
    if ( id == null ) {
      // purge the main entity
      work = new Work( entityType, id, WorkType.PURGE_ALL );
      searchFactoryImplementor.getWorker().performWork( work, transactionContext );

      // purge the subclasses
      Set<Class<?>> subClasses = builder.getMappedSubclasses();
      for ( Class clazz : subClasses ) {
        work = new Work( clazz, id, WorkType.PURGE_ALL );
        searchFactoryImplementor.getWorker().performWork( work, transactionContext );
      }
    }
View Full Code Here

        if ( mappedXClass != null) {
          if ( mappedXClass.isAnnotationPresent( Indexed.class ) ) {
            DirectoryProviderFactory.DirectoryProviders providers = factory.createDirectoryProviders( mappedXClass, cfg, this, reflectionManager );
            //FIXME DocumentBuilder needs to be built by a helper method receiving Class<T> to infer T properly
            //XClass unfortunately is not (yet) genericized: TODO?
            final DocumentBuilder<?> documentBuilder = new DocumentBuilder(
                mappedXClass, context, providers.getProviders(), providers.getSelectionStrategy(),
                reflectionManager
            );

            documentBuilders.put( mappedClass, documentBuilder );
          }
          else {
            //FIXME DocumentBuilder needs to be built by a helper method receiving Class<T> to infer T properly
            //XClass unfortunately is not (yet) genericized: TODO?
            final DocumentBuilder<?> documentBuilder = new DocumentBuilder(
                mappedXClass, context, reflectionManager
            );
            //TODO enhance that, I don't like to expose EntityState
            if ( documentBuilder.getEntityState() != EntityState.NON_INDEXABLE ) {
              containedInOnlyBuilders.put( mappedClass, documentBuilder );
            }
          }
          bindFilterDefs(mappedXClass);
          //TODO should analyzer def for classes at tyher sqme level???
View Full Code Here

        DocumentBuilder<?> builder = builders.get( clazz );
        if ( builder != null ) involvedClasses.addAll( builder.getMappedSubclasses() );
      }

      for (Class clazz : involvedClasses) {
        DocumentBuilder 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 );

        final DirectoryProvider[] directoryProviders = builder.getDirectoryProviderSelectionStrategy().getDirectoryProvidersForAllShards();
        searcherSimilarity = checkSimilarity( searcherSimilarity, builder );
        populateDirectories( directories, directoryProviders, searchFactoryImplementor );
      }
      classesAndSubclasses = involvedClasses;
    }
View Full Code Here

     * even with Lucene 2.1, use of indexWriter to delete is not an option
     * We can only delete by term, and the index doesn't have a termt that
     * uniquely identify the entry. See logic below
     */
    log.trace( "remove from Lucene index: " + entity + "#" + id );
    DocumentBuilder builder = workspace.getDocumentBuilder( entity );
    Term term = builder.getTerm( id );
    IndexReader reader = workspace.getIndexReader( provider, entity );
    TermDocs termDocs = null;
    try {
      //TODO is there a faster way?
      //TODO include TermDocs into the workspace?
View Full Code Here

TOP

Related Classes of org.hibernate.search.engine.DocumentBuilder$PropertiesMetadata

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.