Skip to content

Commit

Permalink
issue #957: changes document type to match mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
mrk-vi committed Jul 8, 2024
1 parent fa750e7 commit 09a0431
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import io.openk9.datasource.pipeline.stages.working.Writer;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.json.Json;
import io.vertx.core.json.JsonObject;
import org.jboss.logging.Logger;
import org.opensearch.client.opensearch.OpenSearchAsyncClient;
import org.opensearch.client.opensearch._types.ErrorCause;
Expand Down Expand Up @@ -236,11 +235,20 @@ private Behavior<Writer.Command> onIndexDocument(IndexDocument indexDocument) {
var bulkOperations = new ArrayList<BulkOperation>();

for (EmbeddingService.EmbeddedChunk chunk : embeddedChunks.list()) {
var document = JsonObject.mapFrom(chunk);

Map<?, ?> acl = (Map<?, ?>) document.getValue("acl");
var document = chunk;

var acl = chunk.acl();
if (acl == null || acl.isEmpty()) {
document.put("acl", Map.of("public", true));
document = new EmbeddingService.EmbeddedChunk(
chunk.indexName(),
chunk.contentId(),
Map.of("public", true),
chunk.number(),
chunk.total(),
chunk.chunkText(),
chunk.vector()
);
}

var bulkOperation = new BulkOperation.Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static CompletionStage<byte[]> getEmbeddedPayload(

String text = documentContext.read(configurations.fieldJsonPath);
String contentId = documentContext.read("$.contentId");
Map<String, List<String>> acl = documentContext.read("$.acl");
Map<String, Object> acl = documentContext.read("$.acl");

return client.getMessages(EmbeddingOuterClass.EmbeddingRequest.newBuilder()
.setApiKey(apiKey)
Expand Down Expand Up @@ -159,7 +159,7 @@ public record EmbeddingConfiguration(
public record EmbeddedChunk(
String indexName,
String contentId,
Map<String, List<String>> acl,
Map<String, Object> acl,
int number,
int total,
String chunkText,
Expand Down

0 comments on commit 09a0431

Please sign in to comment.