Package org.hibernate.search.engine.spi

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


      throw new SearchException( "Unable to load indexed class: " + className, e );
    }
  }

  public static Serializable getDocumentId(SearchFactoryImplementor searchFactoryImplementor, Class<?> clazz, Document document, ConversionContext conversionContext) {
    final DocumentBuilderIndexedEntity builderIndexedEntity = getDocumentBuilder(
        searchFactoryImplementor,
        clazz
    );
    final TwoWayFieldBridge fieldBridge = builderIndexedEntity.getIdBridge();
    final String fieldName = builderIndexedEntity.getIdKeywordName();
    try {
      return (Serializable) conversionContext
          .setClass( clazz )
          .pushIdentifierProperty()
          .twoWayConversionContext( fieldBridge )
View Full Code Here


      conversionContext.popProperty();
    }
  }

  public static String getDocumentIdName(SearchFactoryImplementor searchFactoryImplementor, Class<?> clazz) {
    DocumentBuilderIndexedEntity documentBuilder = getDocumentBuilder( searchFactoryImplementor, clazz );
    return documentBuilder.getIdentifierName();
  }
View Full Code Here

    DocumentBuilderIndexedEntity documentBuilder = getDocumentBuilder( searchFactoryImplementor, clazz );
    return documentBuilder.getIdentifierName();
  }

  public static Object[] getDocumentFields(SearchFactoryImplementor searchFactoryImplementor, Class<?> clazz, Document document, String[] fields, ConversionContext conversionContext) {
    DocumentBuilderIndexedEntity builderIndexedEntity = getDocumentBuilder( searchFactoryImplementor, clazz );
    final int fieldNbr = fields.length;
    Object[] result = new Object[fieldNbr];
    Arrays.fill( result, NOT_SET );
    conversionContext.setClass( clazz );
    if ( builderIndexedEntity.getIdKeywordName() != null ) {
      final String fieldName = builderIndexedEntity.getIdKeywordName();
      int matchingPosition = getFieldPosition( fields, fieldName );
      if ( matchingPosition != -1 ) {
        conversionContext.pushProperty( fieldName );
        try {
          populateResult(
              fieldName,
              builderIndexedEntity.getIdBridge(),
              Store.YES,
              result,
              document,
              conversionContext,
              matchingPosition
          );
        }
        finally {
          conversionContext.popProperty();
        }
      }
    }

    final TypeMetadata metadata = builderIndexedEntity.getMetadata();
    processFieldsForProjection( metadata, fields, result, document, conversionContext );
    return result;
  }
View Full Code Here

  }

  public Query createQuery() {
    Query query;
    final SearchFactoryImplementor searchFactory = queryContext.getFactory();
    final DocumentBuilderIndexedEntity documentBuilder = Helper.getDocumentBuilder( queryContext );
    IndexReader indexReader = searchFactory.getIndexReaderAccessor().open( queryContext.getEntityType() );
    // retrieving the docId and building the more like this query form the term vectors must be using the same index reader
    try {
      String[] fieldNames = getAllCompatibleFieldNames( documentBuilder );
      if ( fieldsContext.size() == 0 ) {
View Full Code Here

  private Query createQuery(FieldContext fieldContext, ConversionContext conversionContext) {
    final Query perFieldQuery;
    final String fieldName = fieldContext.getField();
    final Analyzer queryAnalyzer = queryContext.getQueryAnalyzer();

    final DocumentBuilderIndexedEntity documentBuilder = Helper.getDocumentBuilder( queryContext );

    final FieldBridge fieldBridge = fieldContext.getFieldBridge() != null ? fieldContext.getFieldBridge() : documentBuilder.getBridge( fieldContext.getField() );

    final Object fromObject = rangeContext.getFrom();
    final Object toObject = rangeContext.getTo();

    if ( fieldBridge != null && NumericFieldBridge.class.isAssignableFrom( fieldBridge.getClass() ) ) {
View Full Code Here

  @Override
  public void performWork(LuceneWork work, IndexWriter writer, IndexingMonitor monitor) {
    final Class<?> entityType = work.getEntityClass();
    final Serializable id = work.getId();
    log.tracef( "Removing %s#%s by query.", entityType, id );
    DocumentBuilderIndexedEntity builder = workspace.getDocumentBuilder( entityType );

    BooleanQuery entityDeletionQuery = new BooleanQuery();

    Query idQueryTerm;
    if ( isIdNumeric( builder ) ) {
      idQueryTerm = NumericFieldUtils.createExactMatchQuery( builder.getIdKeywordName(), id );
    }
    else {
      Term idTerm = new Term( builder.getIdKeywordName(), work.getIdInString() );
      idQueryTerm = new TermQuery( idTerm );
    }
    entityDeletionQuery.add( idQueryTerm, BooleanClause.Occur.MUST );

    Term classNameQueryTerm = new Term( ProjectionConstants.OBJECT_CLASS, entityType.getName() );
View Full Code Here

          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

        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

  }

  @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

      // 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

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.