Skip to content

Commit

Permalink
Merge branch 'master' into 0.60
Browse files Browse the repository at this point in the history
# Conflicts:
#	lumongo-cluster/src/main/java/org/lumongo/server/index/LumongoIndex.java
  • Loading branch information
mdavis95 committed Jul 15, 2017
2 parents d8f9f61 + 7050282 commit a43c56e
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -59,10 +60,22 @@ public Response get(@QueryParam(LumongoConstants.INDEX) List<String> indexName,
@QueryParam(LumongoConstants.HIGHLIGHT_JSON) List<String> highlightJsonList,
@QueryParam(LumongoConstants.ANALYZE_JSON) List<String> analyzeJsonList, @QueryParam(LumongoConstants.COS_SIM_JSON) List<String> 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);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -373,11 +386,17 @@ private String buildHeaderForCSV(@QueryParam(LumongoConstants.FIELDS) List<Strin

}

private String getStandardResponse(QueryResponse qr, boolean strict) throws InvalidProtocolBufferException {
private String getStandardResponse(QueryResponse qr, boolean strict, boolean cursor) throws InvalidProtocolBufferException {
StringBuilder responseBuilder = new StringBuilder();
responseBuilder.append("{");
responseBuilder.append("\"totalHits\": ");
responseBuilder.append(qr.getTotalHits());
if (cursor) {
responseBuilder.append(",");
responseBuilder.append("\"cursor\": \"");
responseBuilder.append(CursorHelper.getUniqueSortedCursor(qr.getLastResult()));
responseBuilder.append("\"");
}

if (!qr.getAnalysisResultList().isEmpty()) {
responseBuilder.append(",");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public LumongoQueryParser(Analyzer analyzer, IndexConfig indexConfig) {
super(indexConfig.getIndexSettings().getDefaultSearchField(), analyzer);
this.indexConfig = indexConfig;
setAllowLeadingWildcard(true);
//TODO consider turning this on
//setSplitOnWhitespace(false);
}

private static Long getDateAsLong(String dateString) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,5 @@ public class LumongoConstants {
public static final String DONT_CACHE = "dontCache";
public static final String BATCH = "batch";
public static final String BATCH_SIZE = "batchSize";
public static final String CURSOR = "cursor";
}

0 comments on commit a43c56e

Please sign in to comment.