我正在使用 marklogic 9 和数据移动 api 来导出搜索结果。我创建一个查询,如:
StructuredQueryDefinition query = ...
String sortOptionsXml = "<sort-order direction=\"" + sortDirection + "\">" + "<path-index>" + sortIndex + "</path-index>" + "</sort-order>";
String queryAsXml = "<search xmlns=\"http://marklogic.com/appservices/search\">" + query.serialize()
+ "<options><search-option>filtered</search-option>\n" + sortOptions + "</options>" + "</search>"
RawCombinedQueryDefinition combinedQueryDefinition = queryManager
.newRawCombinedQueryDefinition(new StringHandle().with(queryAsXml).withFormat(Format.XML));
然后我将此查询发送到 QueryBatcher,创建如下:
QueryBatcher batcher = databaseClient.newDataMovementManager().newQueryBatcher(query)
并将批处理器启动为:
batcher.withBatchSize(500)
.withThreadCount(8)
.onUrisReady(
new QueryBatchListener() {
@Override
public void processEvent(QueryBatch queryBatch) {
LOGGER.info(String.join(",", queryBatch.getItems()));
}
}
)
.onQueryFailure(Exception::printStackTrace);
JobTicket jobTicket = dataMovementManager.startJob(batcher);
batcher.awaitCompletion();
dataMovementManager.stopJob(jobTicket);
但是,如果我查看返回的项目,它们不会按我使用的排序选项进行排序,即使在批次内也是如此。是否可以对 URI 进行排序?