Package org.hibernate.search.engine.metadata.impl

Examples of org.hibernate.search.engine.metadata.impl.DocumentFieldMetadata


            Field.TermVector.NO
        );
    doc.add( classField );

    // now add the entity id to the document
    DocumentFieldMetadata idFieldMetaData = idPropertyMetadata.getFieldMetadata( idFieldName );

    LuceneOptions luceneOptions = new LuceneOptionsImpl( idFieldMetaData );
    final FieldBridge contextualizedBridge = conversionContext.oneWayConversionContext( getIdBridge() );
    conversionContext.setClass( entityType );
    conversionContext.pushProperty( idFieldMetaData.getName() );

    try {
      contextualizedBridge.set( idFieldMetaData.getName(), id, doc, luceneOptions );
    }
    finally {
      conversionContext.popProperty();
    }
View Full Code Here


  public String objectToString(String fieldName, Object value, ConversionContext conversionContext) {
    if ( fieldName == null ) {
      throw new AssertionFailure( "Field name should not be null" );
    }

    final DocumentFieldMetadata idFieldMetaData = idPropertyMetadata.getFieldMetadata( idFieldName );
    final FieldBridge bridge = fieldName.equals( idFieldMetaData.getName() ) ?
        getIdBridge() :
        getBridge( getMetadata(), fieldName );

    if ( bridge != null ) {
      return objectToString( fieldName, bridge, value, conversionContext );
View Full Code Here

    return getBridge( getMetadata(), fieldName );
  }

  private FieldBridge getBridge(TypeMetadata typeMetadata, String fieldName) {
    // process base fields
    DocumentFieldMetadata documentFieldMetadata = typeMetadata.getDocumentFieldMetadataFor( fieldName );
    if ( documentFieldMetadata != null && documentFieldMetadata.getFieldBridge() != null ) {
      return documentFieldMetadata.getFieldBridge();
    }

    // process embedded fields
    FieldBridge fieldBridge;

    for ( EmbeddedTypeMetadata embeddedTypeMetadata : typeMetadata.getEmbeddedTypeMetadata() ) {
      fieldBridge = getBridge( embeddedTypeMetadata, fieldName );
      if ( fieldBridge != null ) {
        return fieldBridge;
      }
    }

    // process null embedded fields
    for ( EmbeddedTypeMetadata embeddedTypeMetadata : typeMetadata.getEmbeddedTypeMetadata() ) {
      fieldBridge = getNullBridge( embeddedTypeMetadata, fieldName );
      if ( fieldBridge != null ) {
        return fieldBridge;
      }
    }

    //process class bridges
    DocumentFieldMetadata fieldMetadata = typeMetadata.getFieldMetadataForClassBridgeField( fieldName );
    fieldBridge = fieldMetadata == null ? null : fieldMetadata.getFieldBridge();
    return fieldBridge;
  }
View Full Code Here

      if ( fieldBridge instanceof NumericFieldBridge ) {
        // we probably can do something here
        //TODO how to build the query where we don't have the value?
        throw log.numericFieldCannotBeUsedInMoreLikeThis( fieldContext.getField(), documentBuilder.getBeanClass() );
      }
      DocumentFieldMetadata fieldMetadata = documentBuilder.getTypeMetadata().getDocumentFieldMetadataFor(
          fieldContext.getField()
      );
      if ( fieldMetadata == null ) {
        throw log.unknownFieldNameForMoreLikeThisQuery(
            fieldContext.getField(),
            documentBuilder.getBeanClass().getName()
        );
      }
      boolean hasTermVector = fieldMetadata.getTermVector() != Field.TermVector.NO;
      boolean isStored = fieldMetadata.getStore() != Store.NO;
      if ( ! ( hasTermVector || isStored ) ) {
        throw log.fieldNotStoredNorTermVectorCannotBeUsedInMoreLikeThis( fieldContext.getField(), documentBuilder.getBeanClass() );
      }
      boolean isIdOrEmbeddedId = fieldMetadata.isId() || fieldMetadata.isIdInEmbedded();
      if ( isIdOrEmbeddedId ) {
        throw log.fieldIdCannotBeUsedInMoreLikeThis( fieldContext.getField(), documentBuilder.getBeanClass() );
      }
    }
View Full Code Here

    return id;
  }

  @Override
  public void addWorkToQueue(Class<?> entityClass, Object entity, Serializable id, boolean delete, boolean add, List<LuceneWork> queue, ConversionContext contextualBridge) {
    DocumentFieldMetadata idFieldMetadata = idPropertyMetadata.getFieldMetadata( idFieldName );
    String idInString = objectToString( getIdBridge(), idFieldMetadata.getName(), id, contextualBridge );
    if ( delete && !add ) {
      queue.add( new DeleteLuceneWork( id, idInString, entityClass ) );
    }
    else if ( add && !delete ) {
      queue.add(
View Full Code Here

      doc.add( classField );
    }

    // now add the entity id to the document
    if ( containsFieldName( idFieldName, includedFieldNames ) ) {
      DocumentFieldMetadata idFieldMetaData = idPropertyMetadata.getFieldMetadata( idFieldName );
      LuceneOptions luceneOptions = new LuceneOptionsImpl( idFieldMetaData, idFieldMetaData.getBoost(), documentLevelBoost );
      final FieldBridge contextualizedBridge = conversionContext.oneWayConversionContext( getIdBridge() );
      conversionContext.setClass( entityType );
      conversionContext.pushProperty( idFieldMetaData.getName() );

      try {
        contextualizedBridge.set( idFieldMetaData.getName(), id, doc, luceneOptions );
      }
      finally {
        conversionContext.popProperty();
      }
    }
View Full Code Here

  public String objectToString(String fieldName, Object value, ConversionContext conversionContext) {
    if ( fieldName == null ) {
      throw new AssertionFailure( "Field name should not be null" );
    }

    final DocumentFieldMetadata idFieldMetaData = idPropertyMetadata.getFieldMetadata( idFieldName );
    final FieldBridge bridge = fieldName.equals( idFieldMetaData.getName() ) ?
        getIdBridge() :
        getBridge( getMetadata(), fieldName );

    if ( bridge != null ) {
      return objectToString( fieldName, bridge, value, conversionContext );
View Full Code Here

    return getBridge( getMetadata(), fieldName );
  }

  private FieldBridge getBridge(TypeMetadata typeMetadata, String fieldName) {
    // process base fields
    DocumentFieldMetadata documentFieldMetadata = typeMetadata.getDocumentFieldMetadataFor( fieldName );
    if ( documentFieldMetadata != null && documentFieldMetadata.getFieldBridge() != null ) {
      return documentFieldMetadata.getFieldBridge();
    }

    // process embedded fields
    FieldBridge fieldBridge;

    for ( EmbeddedTypeMetadata embeddedTypeMetadata : typeMetadata.getEmbeddedTypeMetadata() ) {
      fieldBridge = getBridge( embeddedTypeMetadata, fieldName );
      if ( fieldBridge != null ) {
        return fieldBridge;
      }
    }

    // process null embedded fields
    for ( EmbeddedTypeMetadata embeddedTypeMetadata : typeMetadata.getEmbeddedTypeMetadata() ) {
      fieldBridge = getNullBridge( embeddedTypeMetadata, fieldName );
      if ( fieldBridge != null ) {
        return fieldBridge;
      }
    }

    //process class bridges
    DocumentFieldMetadata fieldMetadata = typeMetadata.getFieldMetadataForClassBridgeField( fieldName );
    fieldBridge = fieldMetadata == null ? null : fieldMetadata.getFieldBridge();
    return fieldBridge;
  }
View Full Code Here

         SortField[] sortField = new SortField[sortCriteria.size()];
         int i = 0;
         for (SortCriteria sc : sortCriteria) {
            //TODO [anistor] sort type is not entirely correct
            PropertyMetadata propMetadata = getPropertyMetadata(parsingResult.getTargetEntity(), sc.getAttributePath());
            DocumentFieldMetadata fm = propMetadata.getFieldMetadata().iterator().next();
            int sortType = fm.isNumeric() ? SortField.INT : SortField.STRING;
            sortField[i++] = new SortField(sc.getAttributePath(), sortType, sc.getSortOrder() == SortOrder.DESC);
         }
         sort = new Sort(sortField);
      }
View Full Code Here

      providedIdFieldName = ProvidedId.defaultFieldName;
      idProvided = true;
    }

    if ( idProvided ) {
      DocumentFieldMetadata fieldMetadata =
          new DocumentFieldMetadata.Builder(
              providedIdFieldName,
              Store.YES,
              Field.Index.NOT_ANALYZED_NO_NORMS,
              Field.TermVector.NO
View Full Code Here

TOP

Related Classes of org.hibernate.search.engine.metadata.impl.DocumentFieldMetadata

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.