Skip to content

Commit

Permalink
Fix setting setting id in bulkrequest.
Browse files Browse the repository at this point in the history
Original Pull Request #2862
Closes #2861

(cherry picked from commit debf04b)
(cherry picked from commit b52e8d1)
  • Loading branch information
sothawo committed Feb 28, 2024
1 parent a952e10 commit e105648
Showing 1 changed file with 14 additions and 13 deletions.
Expand Up @@ -539,13 +539,12 @@ public IndexRequest<?> documentIndexRequest(IndexQuery query, IndexCoordinates i
Object queryObject = query.getObject();

if (queryObject != null) {
String id = StringUtils.hasText(query.getId()) ? query.getId() : getPersistentEntityId(queryObject);
builder //
.id(id) //
builder
.id(StringUtils.hasText(query.getId()) ? query.getId() : getPersistentEntityId(queryObject))
.document(elasticsearchConverter.mapObject(queryObject));
} else if (query.getSource() != null) {
builder //
.id(query.getId()) //
builder
.id(query.getId())
.document(new DefaultStringObjectMap<>().fromJson(query.getSource()));
} else {
throw new InvalidDataAccessApiUsageException(
Expand Down Expand Up @@ -591,12 +590,13 @@ private IndexOperation<?> bulkIndexOperation(IndexQuery query, IndexCoordinates
Object queryObject = query.getObject();

if (queryObject != null) {
String id = StringUtils.hasText(query.getId()) ? query.getId() : getPersistentEntityId(queryObject);
builder //
.id(id) //
builder
.id(StringUtils.hasText(query.getId()) ? query.getId() : getPersistentEntityId(queryObject))
.document(elasticsearchConverter.mapObject(queryObject));
} else if (query.getSource() != null) {
builder.document(new DefaultStringObjectMap<>().fromJson(query.getSource()));
builder
.id(query.getId())
.document(new DefaultStringObjectMap<>().fromJson(query.getSource()));
} else {
throw new InvalidDataAccessApiUsageException(
"object or source is null, failed to index the document [id: " + query.getId() + ']');
Expand Down Expand Up @@ -632,12 +632,13 @@ private CreateOperation<?> bulkCreateOperation(IndexQuery query, IndexCoordinate
Object queryObject = query.getObject();

if (queryObject != null) {
String id = StringUtils.hasText(query.getId()) ? query.getId() : getPersistentEntityId(queryObject);
builder //
.id(id) //
builder
.id(StringUtils.hasText(query.getId()) ? query.getId() : getPersistentEntityId(queryObject))
.document(elasticsearchConverter.mapObject(queryObject));
} else if (query.getSource() != null) {
builder.document(new DefaultStringObjectMap<>().fromJson(query.getSource()));
builder
.id(query.getId())
.document(new DefaultStringObjectMap<>().fromJson(query.getSource()));
} else {
throw new InvalidDataAccessApiUsageException(
"object or source is null, failed to index the document [id: " + query.getId() + ']');
Expand Down

0 comments on commit e105648

Please sign in to comment.