diff --git a/build.gradle b/build.gradle index 78ff7aef..1cfdd20c 100644 --- a/build.gradle +++ b/build.gradle @@ -34,6 +34,9 @@ subprojects { mavenCentral() flatDir name: 'directoryRepository', dirs: rootProject.file('notInMaven') + //maven { + //url "https://dist.apache.org/repos/dist/dev/lucene/lucene-solr-6.6.0-RC1-rev4d055f00bba9a745737e4b6c3f9dff06dd35aa2e/lucene/maven/" + //} } dependencies { diff --git a/lumongo-cluster/src/main/java/org/lumongo/server/index/LumongoIndex.java b/lumongo-cluster/src/main/java/org/lumongo/server/index/LumongoIndex.java index ac0fa11d..bd9ac013 100644 --- a/lumongo-cluster/src/main/java/org/lumongo/server/index/LumongoIndex.java +++ b/lumongo-cluster/src/main/java/org/lumongo/server/index/LumongoIndex.java @@ -884,7 +884,9 @@ public void deleteDocument(DeleteRequest deleteRequest) throws Exception { if (deleteRequest.getDeleteDocument()) { LumongoSegment s = findSegmentFromUniqueId(deleteRequest.getUniqueId()); s.deleteDocument(uniqueId); - documentStorage.deleteSourceDocument(uniqueId); + if (indexConfig.getIndexSettings().getStoreDocumentInMongo()) { + documentStorage.deleteSourceDocument(uniqueId); + } } if (deleteRequest.getDeleteAllAssociated()) { diff --git a/lumongo-cluster/src/main/java/org/lumongo/server/rest/QueryResource.java b/lumongo-cluster/src/main/java/org/lumongo/server/rest/QueryResource.java index ca88c010..e143ec7d 100644 --- a/lumongo-cluster/src/main/java/org/lumongo/server/rest/QueryResource.java +++ b/lumongo-cluster/src/main/java/org/lumongo/server/rest/QueryResource.java @@ -7,6 +7,7 @@ import org.apache.log4j.Logger; import org.bson.Document; import org.lumongo.LumongoConstants; +import org.lumongo.client.command.CursorHelper; import org.lumongo.cluster.message.Lumongo; import org.lumongo.cluster.message.Lumongo.CountRequest; import org.lumongo.cluster.message.Lumongo.FacetRequest; @@ -59,10 +60,22 @@ public Response get(@QueryParam(LumongoConstants.INDEX) List indexName, @QueryParam(LumongoConstants.HIGHLIGHT_JSON) List highlightJsonList, @QueryParam(LumongoConstants.ANALYZE_JSON) List analyzeJsonList, @QueryParam(LumongoConstants.COS_SIM_JSON) List cosineSimJsonList, @QueryParam(LumongoConstants.FORMAT) @DefaultValue("json") String format, @QueryParam(LumongoConstants.BATCH) boolean batch, - @QueryParam(LumongoConstants.BATCH_SIZE) @DefaultValue("500") Integer batchSize) { + @QueryParam(LumongoConstants.BATCH_SIZE) @DefaultValue("500") Integer batchSize, @QueryParam(LumongoConstants.CURSOR) String cursor) { QueryRequest.Builder qrBuilder = QueryRequest.newBuilder().addAllIndex(indexName); + boolean outputCursor = false; + if (cursor != null) { + if (!cursor.equals("0")) { + qrBuilder.setLastResult(CursorHelper.getLastResultFromCursor(cursor)); + } + outputCursor = true; + if (sort == null || sort.isEmpty()) { + return Response.status(LumongoConstants.INTERNAL_ERROR) + .entity("Sort on unique value or value combination is required to use a cursor (i.e. id or title,id)").build(); + } + } + if (debug != null) { qrBuilder.setDebug(debug); } @@ -292,7 +305,7 @@ else if ("1".equals(sortDir) || "ASC".equalsIgnoreCase(sortDir)) { try { if (format.equals("json")) { QueryResponse qr = indexManager.query(qrBuilder.build()); - String response = getStandardResponse(qr, !pretty); + String response = getStandardResponse(qr, !pretty, outputCursor); if (pretty) { response = JsonWriter.formatJson(response); @@ -373,11 +386,17 @@ private String buildHeaderForCSV(@QueryParam(LumongoConstants.FIELDS) List