Search in sources :

Example 6 with SearchServerException

use of com.rbmhtechnology.vind.SearchServerException in project vind by RBMHTechnology.

the class SolrSearchServer method clearIndex.

@Override
public void clearIndex() {
    try {
        solrClientLogger.debug(">>> clear complete index");
        solrClient.deleteByQuery("*:*");
    } catch (SolrServerException | IOException e) {
        log.error("Cannot clear index", e);
        throw new SearchServerException("Cannot clear index", e);
    }
}
Also used : SolrServerException(org.apache.solr.client.solrj.SolrServerException) IOException(java.io.IOException) SearchServerException(com.rbmhtechnology.vind.SearchServerException)

Example 7 with SearchServerException

use of com.rbmhtechnology.vind.SearchServerException in project vind by RBMHTechnology.

the class SolrSearchServer method execute.

@Override
public SearchResult execute(FulltextSearch search, DocumentFactory factory) {
    final SolrQuery query = buildSolrQuery(search, factory);
    // query
    try {
        solrClientLogger.debug(">>> query({})", query.toString());
        final QueryResponse response = solrClient.query(query, SolrRequest.METHOD.POST);
        if (response != null) {
            final Map<String, Integer> childCounts = SolrUtils.getChildCounts(response);
            final List<Document> documents = SolrUtils.Result.buildResultList(response.getResults(), childCounts, factory, search.getSearchContext());
            final FacetResults facetResults = SolrUtils.Result.buildFacetResult(response, factory, search.getChildrenFactory(), search.getFacets(), search.getSearchContext());
            switch(search.getResultSet().getType()) {
                case page:
                    {
                        return new PageResult(response.getResults().getNumFound(), response.getQTime(), documents, search, facetResults, this, factory).setElapsedTime(response.getElapsedTime());
                    }
                case slice:
                    {
                        return new SliceResult(response.getResults().getNumFound(), response.getQTime(), documents, search, facetResults, this, factory).setElapsedTime(response.getElapsedTime());
                    }
                default:
                    return new PageResult(response.getResults().getNumFound(), response.getQTime(), documents, search, facetResults, this, factory).setElapsedTime(response.getElapsedTime());
            }
        } else {
            throw new SolrServerException("Null result from SolrClient");
        }
    } catch (SolrServerException | IOException e) {
        throw new SearchServerException("Cannot issue query", e);
    }
}
Also used : SolrServerException(org.apache.solr.client.solrj.SolrServerException) IOException(java.io.IOException) SolrInputDocument(org.apache.solr.common.SolrInputDocument) Document(com.rbmhtechnology.vind.api.Document) SolrDocument(org.apache.solr.common.SolrDocument) SolrQuery(org.apache.solr.client.solrj.SolrQuery) QueryResponse(org.apache.solr.client.solrj.response.QueryResponse) SearchServerException(com.rbmhtechnology.vind.SearchServerException)

Example 8 with SearchServerException

use of com.rbmhtechnology.vind.SearchServerException in project vind by RBMHTechnology.

the class SolrSearchServer method execute.

@Override
public SuggestionResult execute(ExecutableSuggestionSearch search, DocumentFactory assets, DocumentFactory childFactory) {
    SolrQuery query = buildSolrQuery(search, assets, childFactory);
    try {
        log.debug(">>> query({})", query.toString());
        QueryResponse response = solrClient.query(query, SolrRequest.METHOD.POST);
        if (response != null) {
            return SolrUtils.Result.buildSuggestionResult(response, assets, childFactory, search.getSearchContext());
        } else {
            log.error("Null result from SolrClient");
            throw new SolrServerException("Null result from SolrClient");
        }
    } catch (SolrServerException | IOException e) {
        log.error("Cannot execute suggestion query");
        throw new SearchServerException("Cannot execute suggestion query", e);
    }
}
Also used : QueryResponse(org.apache.solr.client.solrj.response.QueryResponse) SolrServerException(org.apache.solr.client.solrj.SolrServerException) IOException(java.io.IOException) SearchServerException(com.rbmhtechnology.vind.SearchServerException) SolrQuery(org.apache.solr.client.solrj.SolrQuery)

Example 9 with SearchServerException

use of com.rbmhtechnology.vind.SearchServerException in project vind by RBMHTechnology.

the class SolrSearchServer method execute.

@Override
public GetResult execute(RealTimeGet search, DocumentFactory assets) {
    SolrQuery query = buildSolrQuery(search, assets);
    try {
        log.debug(">>> query({})", query.toString());
        QueryResponse response = solrClient.query(query, SolrRequest.METHOD.POST);
        if (response != null) {
            return SolrUtils.Result.buildRealTimeGetResult(response, search, assets);
        } else {
            log.error("Null result from SolrClient");
            throw new SolrServerException("Null result from SolrClient");
        }
    } catch (SolrServerException | IOException e) {
        log.error("Cannot execute realTime get query");
        throw new SearchServerException("Cannot execute realTime get query", e);
    }
}
Also used : QueryResponse(org.apache.solr.client.solrj.response.QueryResponse) SolrServerException(org.apache.solr.client.solrj.SolrServerException) IOException(java.io.IOException) SearchServerException(com.rbmhtechnology.vind.SearchServerException) SolrQuery(org.apache.solr.client.solrj.SolrQuery)

Aggregations

SearchServerException (com.rbmhtechnology.vind.SearchServerException)9 IOException (java.io.IOException)9 SolrServerException (org.apache.solr.client.solrj.SolrServerException)9 SolrInputDocument (org.apache.solr.common.SolrInputDocument)4 Document (com.rbmhtechnology.vind.api.Document)3 SolrQuery (org.apache.solr.client.solrj.SolrQuery)3 QueryResponse (org.apache.solr.client.solrj.response.QueryResponse)3 Resources (com.google.common.io.Resources)2 AnnotationUtil (com.rbmhtechnology.vind.annotations.AnnotationUtil)2 SearchServer (com.rbmhtechnology.vind.api.SearchServer)2 ServiceProvider (com.rbmhtechnology.vind.api.ServiceProvider)2 com.rbmhtechnology.vind.api.query (com.rbmhtechnology.vind.api.query)2 Delete (com.rbmhtechnology.vind.api.query.delete.Delete)2 Page (com.rbmhtechnology.vind.api.query.division.Page)2 Slice (com.rbmhtechnology.vind.api.query.division.Slice)2 Facet (com.rbmhtechnology.vind.api.query.facet.Facet)2 Interval (com.rbmhtechnology.vind.api.query.facet.Interval)2 RealTimeGet (com.rbmhtechnology.vind.api.query.get.RealTimeGet)2 DescriptorSuggestionSearch (com.rbmhtechnology.vind.api.query.suggestion.DescriptorSuggestionSearch)2 ExecutableSuggestionSearch (com.rbmhtechnology.vind.api.query.suggestion.ExecutableSuggestionSearch)2