Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,6 @@ protected ElasticsearchVectorStore(Builder builder) {

@Override
public void doAdd(List<Document> documents) {
// For the index to be present, either it must be pre-created or set the
// initializeSchema to true.
if (!indexExists()) {
throw new IllegalArgumentException("Index not found");
}
BulkRequest.Builder bulkRequestBuilder = new BulkRequest.Builder();

List<float[]> embeddings = this.embeddingModel.embed(documents, EmbeddingOptionsBuilder.builder().build(),
Expand Down Expand Up @@ -214,11 +209,6 @@ private Object getDocument(Document document, float[] embedding, String embeddin
@Override
public void doDelete(List<String> idList) {
BulkRequest.Builder bulkRequestBuilder = new BulkRequest.Builder();
// For the index to be present, either it must be pre-created or set the
// initializeSchema to true.
if (!indexExists()) {
throw new IllegalArgumentException("Index not found");
}
for (String id : idList) {
bulkRequestBuilder.operations(op -> op.delete(idx -> idx.index(this.options.getIndexName()).id(id)));
}
Expand All @@ -229,12 +219,6 @@ public void doDelete(List<String> idList) {

@Override
public void doDelete(Filter.Expression filterExpression) {
// For the index to be present, either it must be pre-created or set the
// initializeSchema to true.
if (!indexExists()) {
throw new IllegalArgumentException("Index not found");
}

try {
this.elasticsearchClient.deleteByQuery(d -> d.index(this.options.getIndexName())
.query(q -> q.queryString(qs -> qs.query(getElasticsearchQueryString(filterExpression)))));
Expand Down Expand Up @@ -349,12 +333,15 @@ private DenseVectorSimilarity parseSimilarity(String similarity) {

@Override
public void afterPropertiesSet() {
if (!this.initializeSchema) {
// For the index to be present, either it must be pre-created or set the
// initializeSchema to true.
if (indexExists()) {
return;
}
if (!indexExists()) {
createIndexMapping();
if (!this.initializeSchema) {
throw new IllegalArgumentException("Index not found");
}
createIndexMapping();
}

@Override
Expand Down