Project

General

Profile

« Previous | Next » 

Revision 57207

Reports always download the first 2000 results. Dedup organizations returned #4588

View differences:

SolrResultSet.java
177 177

  
178 178
        queryOpts.add("start", from*to + "");
179 179
        queryOpts.add("rows", to +"");
180
        //queryOpts.add("f.resulthostingdatasource.facet.limit", "2");
180 181

  
181 182
        long startTime = System.nanoTime();
182 183

  
......
294 295
        return null;
295 296
    }
296 297

  
297
    public void cursorGet(Transformer transformer, OutputStream os) throws SolrServerException, SearchServiceException {
298
    /**
299
     * limit is the maximum number of results the cursor get is allowed to fetch. If limit is set to -1 all
300
     * results are returned.
301
     */
302
    public void cursorGet(Transformer transformer, int limit, OutputStream os) throws SolrServerException, SearchServiceException {
303

  
304
        int rows = 500;
305
        int limitCounter = -1;
306

  
298 307
        queryOpts.add("start", "0");
299 308
        queryOpts.add("rows", "0");
300 309
        queryOpts.remove("rows");
301
        queryOpts.add("rows", "500");
310
        queryOpts.add("rows", rows+"");
302 311
        queryOpts.add("fl", "__result");
303 312
        queryOpts.add("shards.tolerant","true");
304 313
        queryOpts.add("cursorMark", "*");
......
307 316
        String cursorMark = "*";
308 317
        String nextCursorMark = "";
309 318

  
310
        int curs = 0;
319
        if ( limit > 0 ) {
320
            limitCounter = limit/rows;
321
            logger.info("limit counter " + limitCounter);
322
        }
323

  
311 324
        try {
312 325
            QueryResponse resp = solrClient.query(SolrParams.toSolrParams(queryOpts));
313 326

  
314
            while (!cursorMark.equals(nextCursorMark)) {
327
            while (!cursorMark.equals(nextCursorMark) && ( limitCounter > 0 || limitCounter == -1)) {
328
                //logger.info(">> " + limitCounter);
315 329
                resp = solrClient.query(SolrParams.toSolrParams(queryOpts));
316 330
                cursorMark = nextCursorMark;
317 331
                nextCursorMark = resp.getNextCursorMark();
......
320 334
                    if (transformer != null) {
321 335
                        String result = null;
322 336
                        try {
337
                            logger.debug("PRE RESULT " + resp.getResults().get(i).get("__result"));
323 338
                            result = transformer.transform((String) resp.getResults().get(i).get("__result"));
324 339
                            logger.debug("RESULT " + result);
325 340

  
......
340 355

  
341 356
                queryOpts.remove("cursorMark");
342 357
                queryOpts.add("cursorMark", nextCursorMark);
343
                curs++;
358
                limitCounter--;
344 359
            }
345 360

  
346 361
        } catch (IOException ioe) {
347 362
            logger.error("Error executing solr query. ", ioe);
348 363
        }
349

  
350
        logger.debug("CURS " + curs);
351 364
    }
352 365

  
353 366

  

Also available in: Unified diff