Search in sources :

Example 1 with VUserException

use of io.vertigo.lang.VUserException in project vertigo by KleeGroup.

the class RamLuceneIndex method executeQuery.

private DtList<D> executeQuery(final Query query, final int skip, final int top, final Optional<Sort> optSort) throws IOException {
    try (final IndexReader indexReader = DirectoryReader.open(directory)) {
        final IndexSearcher searcher = new IndexSearcher(indexReader);
        // 1. Exécution des la Requête
        final TopDocs topDocs;
        if (optSort.isPresent()) {
            topDocs = searcher.search(query, skip + top, optSort.get());
        } else {
            topDocs = searcher.search(query, skip + top);
        }
        // 2. Traduction du résultat Lucene en une Collection
        return translateDocs(searcher, topDocs, skip, top);
    } catch (final TooManyClauses e) {
        throw (VUserException) new VUserException(Resources.DYNAMO_COLLECTIONS_INDEXER_TOO_MANY_CLAUSES).initCause(e);
    }
}
Also used : IndexSearcher(org.apache.lucene.search.IndexSearcher) TopDocs(org.apache.lucene.search.TopDocs) IndexReader(org.apache.lucene.index.IndexReader) TooManyClauses(org.apache.lucene.search.BooleanQuery.TooManyClauses) VUserException(io.vertigo.lang.VUserException)

Example 2 with VUserException

use of io.vertigo.lang.VUserException in project vertigo by KleeGroup.

the class RamLuceneIndex method executeQuery.

private DtList<D> executeQuery(final Query query, final int skip, final int top, final Optional<Sort> optSort) throws IOException {
    try (final IndexReader indexReader = DirectoryReader.open(directory)) {
        final IndexSearcher searcher = new IndexSearcher(indexReader);
        // 1. Exécution des la Requête
        final TopDocs topDocs;
        if (optSort.isPresent()) {
            topDocs = searcher.search(query, skip + top, optSort.get());
        } else {
            topDocs = searcher.search(query, skip + top);
        }
        // 2. Traduction du résultat Lucene en une Collection
        return translateDocs(searcher, topDocs, skip, top);
    } catch (final TooManyClauses e) {
        throw (VUserException) new VUserException(Resources.DYNAMO_COLLECTIONS_INDEXER_TOO_MANY_CLAUSES).initCause(e);
    }
}
Also used : IndexSearcher(org.apache.lucene.search.IndexSearcher) TopDocs(org.apache.lucene.search.TopDocs) IndexReader(org.apache.lucene.index.IndexReader) TooManyClauses(org.apache.lucene.search.BooleanQuery.TooManyClauses) VUserException(io.vertigo.lang.VUserException)

Example 3 with VUserException

use of io.vertigo.lang.VUserException in project vertigo by KleeGroup.

the class AbstractSqlExceptionHandler method handleTooLargeValueSqlException.

/**
 * @param sqle Exception base de données
 */
protected final VUserException handleTooLargeValueSqlException(final SQLException sqle) {
    final MessageKey key = Resources.DYNAMO_SQL_CONSTRAINT_TOO_BIG_VALUE;
    LOGGER.warn(MessageText.of(key).getDisplay(), sqle);
    // On se contente de logger l'exception cause mais on ne la lie pas à l'erreur utilisateur.
    return new VUserException(key);
}
Also used : MessageKey(io.vertigo.core.locale.MessageKey) VUserException(io.vertigo.lang.VUserException)

Example 4 with VUserException

use of io.vertigo.lang.VUserException in project vertigo by KleeGroup.

the class ESStatement method remove.

/**
 * Supprime des documents.
 * @param query Requete de filtrage des documents à supprimer
 */
void remove(final ListFilter query) {
    Assertion.checkNotNull(query);
    // -----
    try {
        final QueryBuilder queryBuilder = ESSearchRequestBuilder.translateToQueryBuilder(query);
        final DeleteByQueryRequestBuilder deleteByQueryAction = DeleteByQueryAction.INSTANCE.newRequestBuilder(esClient).filter(queryBuilder);
        deleteByQueryAction.source().setIndices(indexName).setTypes(typeName);
        final BulkByScrollResponse response = deleteByQueryAction.get();
        final long deleted = response.getDeleted();
        LOGGER.debug("Removed {0} elements", deleted);
    } catch (final SearchPhaseExecutionException e) {
        final VUserException vue = new VUserException(SearchResource.DYNAMO_SEARCH_QUERY_SYNTAX_ERROR);
        vue.initCause(e);
        throw vue;
    }
}
Also used : SearchPhaseExecutionException(org.elasticsearch.action.search.SearchPhaseExecutionException) QueryBuilder(org.elasticsearch.index.query.QueryBuilder) DeleteByQueryRequestBuilder(org.elasticsearch.index.reindex.DeleteByQueryRequestBuilder) BulkByScrollResponse(org.elasticsearch.index.reindex.BulkByScrollResponse) VUserException(io.vertigo.lang.VUserException)

Example 5 with VUserException

use of io.vertigo.lang.VUserException in project vertigo by KleeGroup.

the class ESStatement method loadList.

/**
 * @param indexDefinition Index de recherche
 * @param searchQuery Mots clés de recherche
 * @param listState Etat de la liste (tri et pagination)
 * @param defaultMaxRows Nombre de ligne max par defaut
 * @return Résultat de la recherche
 */
FacetedQueryResult<I, SearchQuery> loadList(final SearchIndexDefinition indexDefinition, final SearchQuery searchQuery, final DtListState listState, final int defaultMaxRows) {
    Assertion.checkNotNull(searchQuery);
    // -----
    final SearchRequestBuilder searchRequestBuilder = new ESSearchRequestBuilder(indexName, typeName, esClient).withSearchIndexDefinition(indexDefinition).withSearchQuery(searchQuery).withListState(listState, defaultMaxRows).build();
    LOGGER.info("loadList " + searchRequestBuilder);
    try {
        final SearchResponse queryResponse = searchRequestBuilder.execute().actionGet();
        return new ESFacetedQueryResultBuilder(esDocumentCodec, indexDefinition, queryResponse, searchQuery).build();
    } catch (final SearchPhaseExecutionException e) {
        final VUserException vue = new VUserException(SearchResource.DYNAMO_SEARCH_QUERY_SYNTAX_ERROR);
        vue.initCause(e);
        throw vue;
    }
}
Also used : SearchRequestBuilder(org.elasticsearch.action.search.SearchRequestBuilder) SearchPhaseExecutionException(org.elasticsearch.action.search.SearchPhaseExecutionException) SearchResponse(org.elasticsearch.action.search.SearchResponse) VUserException(io.vertigo.lang.VUserException)

Aggregations

VUserException (io.vertigo.lang.VUserException)10 SearchPhaseExecutionException (org.elasticsearch.action.search.SearchPhaseExecutionException)4 SearchRequestBuilder (org.elasticsearch.action.search.SearchRequestBuilder)3 SearchResponse (org.elasticsearch.action.search.SearchResponse)3 MessageKey (io.vertigo.core.locale.MessageKey)2 IndexReader (org.apache.lucene.index.IndexReader)2 TooManyClauses (org.apache.lucene.search.BooleanQuery.TooManyClauses)2 IndexSearcher (org.apache.lucene.search.IndexSearcher)2 TopDocs (org.apache.lucene.search.TopDocs)2 QueryBuilder (org.elasticsearch.index.query.QueryBuilder)2 MessageText (io.vertigo.core.locale.MessageText)1 VSystemException (io.vertigo.lang.VSystemException)1 WebServices (io.vertigo.vega.webservice.WebServices)1 Address (io.vertigo.vega.webservice.data.domain.Address)1 Contact (io.vertigo.vega.webservice.data.domain.Contact)1 ContactView (io.vertigo.vega.webservice.data.domain.ContactView)1 SessionException (io.vertigo.vega.webservice.exception.SessionException)1 VSecurityException (io.vertigo.vega.webservice.exception.VSecurityException)1 WebServiceDefinition (io.vertigo.vega.webservice.metamodel.WebServiceDefinition)1 GET (io.vertigo.vega.webservice.stereotype.GET)1