Package org.hibernate.search.exception

Examples of org.hibernate.search.exception.SearchException


      Calendar calendar = Calendar.getInstance();
      calendar.setTime( date );
      return calendar;
    }
    catch (ParseException e) {
      throw new SearchException( "Unable to parse into calendar: " + stringValue, e );
    }
  }
View Full Code Here


      int max = max( first, queryHits.getTotalHits() );
      return buildDocumentExtractor( openSearcher, queryHits, first, max );
    }
    catch (IOException e) {
      closeSearcher( openSearcher );
      throw new SearchException( "Unable to query Lucene index", e );
    }
  }
View Full Code Here

        try {
          QueryHits queryHits = getQueryHits( searcher, 0 );
          resultSize = queryHits.getTotalHits();
        }
        catch (IOException e) {
          throw new SearchException( "Unable to query Lucene index", e );
        }
        finally {
          closeSearcher( searcher );
        }
      }
View Full Code Here

  public Explanation explain(int documentId) {
    //don't use TimeoutManager here as explain is a dev tool when things are weird... or slow :)
    Explanation explanation = null;
    LazyQueryState searcher = buildSearcher( searchFactoryImplementor, true );
    if ( searcher == null ) {
      throw new SearchException(
          "Unable to build explanation for document id:"
              + documentId + ". no index found"
      );
    }
    try {
      org.apache.lucene.search.Query filteredQuery = filterQueryByClasses( luceneQuery );
      buildFilters();
      explanation = searcher.explain( filteredQuery, documentId );
    }
    catch (IOException e) {
      throw new SearchException( "Unable to query Lucene index and build explanation", e );
    }
    finally {
      closeSearcher( searcher );
    }
    return explanation;
View Full Code Here

    //TODO check if caching this work for the last n list of indexedTargetedEntities makes a perf boost
    if ( indexedTargetedEntities.size() == 0 ) {
      // empty indexedTargetedEntities array means search over all indexed entities,
      // but we have to make sure there is at least one
      if ( builders.isEmpty() ) {
        throw new SearchException(
            "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();
View Full Code Here

  private Similarity checkSimilarity(Similarity similarity, Similarity entitySimilarity) {
    if ( similarity == null ) {
      similarity = entitySimilarity;
    }
    else if ( !similarity.getClass().equals( entitySimilarity.getClass() ) ) {
      throw new SearchException(
          "Cannot perform search on two entities with differing Similarity implementations (" + similarity.getClass()
              .getName() + " & " + entitySimilarity.getClass().getName() + ")"
      );
    }
View Full Code Here

    if ( def.getFactoryMethod() != null ) {
      try {
        filter = (Filter) def.getFactoryMethod().invoke( instance );
      }
      catch (IllegalAccessException e) {
        throw new SearchException(
            "Unable to access @Factory method: "
                + def.getImpl().getName() + "." + def.getFactoryMethod().getName(), e
        );
      }
      catch (InvocationTargetException e) {
        throw new SearchException(
            "Unable to access @Factory method: "
                + def.getImpl().getName() + "." + def.getFactoryMethod().getName(), e
        );
      }
      catch (ClassCastException e) {
        throw new SearchException(
            "@Key method does not return a org.apache.lucene.search.Filter class: "
                + def.getImpl().getName() + "." + def.getFactoryMethod().getName(), e
        );
      }
    }
    else {
      try {
        filter = (Filter) instance;
      }
      catch (ClassCastException e) {
        throw new SearchException(
            "Filter implementation does not implement the Filter interface: "
                + def.getImpl().getName() + ". "
                + ( def.getFactoryMethod() != null ? def.getFactoryMethod().getName() : "" ), e
        );
      }
View Full Code Here

    else {
      try {
        key = (FilterKey) def.getKeyMethod().invoke( instance );
      }
      catch (IllegalAccessException e) {
        throw new SearchException(
            "Unable to access @Key method: "
                + def.getImpl().getName() + "." + def.getKeyMethod().getName()
        );
      }
      catch (InvocationTargetException e) {
        throw new SearchException(
            "Unable to access @Key method: "
                + def.getImpl().getName() + "." + def.getKeyMethod().getName()
        );
      }
      catch (ClassCastException e) {
        throw new SearchException(
            "@Key method does not return FilterKey: "
                + def.getImpl().getName() + "." + def.getKeyMethod().getName()
        );
      }
    }
View Full Code Here

    for ( Map.Entry<String, Object> entry : fullTextFilter.getParameters().entrySet() ) {
      def.invoke( entry.getKey(), instance, entry.getValue() );
    }
    if ( cacheInstance( def.getCacheMode() ) && def.getKeyMethod() == null && fullTextFilter.getParameters()
        .size() > 0 ) {
      throw new SearchException( "Filter with parameters and no @Key method: " + fullTextFilter.getName() );
    }
    return instance;
  }
View Full Code Here

  }

  @Override
  public void addTokenTrackingAttribute(List<Integer> positions) {
    //TokenTrackingAttribute is no longer available
    throw new SearchException( "Serialization of TokenTrackingAttribute is no longer supported" );
  }
View Full Code Here

TOP

Related Classes of org.hibernate.search.exception.SearchException

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.