コード例 #1
0
 /**
  * @return the query used to fetch the documents from the Solr index
  * @throws SolrIndexerException if we fail to obtain a query for the configured root entity
  */
 private SolrQuery getQuery() throws SolrIndexerException {
   if (query == null) {
     query = new SolrQuery(solrReferenceResolver.getQuery(rootReference));
     query.setFields(
         FieldUtils.WIKI,
         FieldUtils.SPACES,
         FieldUtils.NAME,
         FieldUtils.DOCUMENT_LOCALE,
         FieldUtils.VERSION);
     query.addFilterQuery(FieldUtils.TYPE + ':' + EntityType.DOCUMENT.name());
     // We sort by ID, which is normally the serialized document reference, in order to ensure this
     // iterator has
     // the same order as the database iterator.
     query.addSort(FieldUtils.ID, ORDER.asc);
     // Paginate using a cursor because it performs better than basic pagination (using absolute
     // offset,
     // especially when the offset is big) and because the impact of index modifications is much
     // smaller (and we
     // plan to update the index to match the database during the synchronization process).
     // See https://cwiki.apache.org/confluence/display/solr/Pagination+of+Results
     query.set(CursorMarkParams.CURSOR_MARK_PARAM, CursorMarkParams.CURSOR_MARK_START);
     query.setRows(LIMIT);
   }
   return query;
 }
コード例 #2
0
 /**
  * @return the query used to fetch the documents from the Solr index
  * @throws SolrIndexerException if we fail to obtain a query for the configured root entity
  */
 private SolrQuery getQuery() throws SolrIndexerException {
   if (query == null) {
     query = new SolrQuery(solrReferenceResolver.getQuery(rootReference));
     query.setFields(
         FieldUtils.WIKI,
         FieldUtils.SPACE,
         FieldUtils.NAME,
         FieldUtils.DOCUMENT_LOCALE,
         FieldUtils.VERSION);
     query.addFilterQuery(FieldUtils.TYPE + ':' + EntityType.DOCUMENT.name());
     // We must add the unique key field (ID in our case) to the list of sort fields (as a tie
     // breaker) in order
     // to use the cursor-based pagination.
     query
         .addSort(FieldUtils.WIKI, ORDER.asc)
         .addSort(FieldUtils.SPACE_EXACT, ORDER.asc)
         .addSort(FieldUtils.NAME_EXACT, ORDER.asc)
         .addSort(FieldUtils.DOCUMENT_LOCALE, ORDER.asc)
         .addSort(FieldUtils.ID, ORDER.asc);
     // Speed up the query by disabling the faceting and the highlighting.
     query.set(FacetParams.FACET, false);
     query.set(HighlightParams.HIGHLIGHT, false);
     // Paginate using a cursor because it performs better than basic pagination (using absolute
     // offset,
     // especially when the offset is big) and because the impact of index modifications is much
     // smaller (and we
     // plan to update the index to match the database during the synchronization process).
     // See https://cwiki.apache.org/confluence/display/solr/Pagination+of+Results
     query.set(CursorMarkParams.CURSOR_MARK_PARAM, CursorMarkParams.CURSOR_MARK_START);
     query.setRows(LIMIT);
   }
   return query;
 }