use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.bulk.BulkRequest in project jmix by jmix-framework.
the class EntityIndexerImpl method deleteByGroupedIndexIds.
protected IndexResult deleteByGroupedIndexIds(Map<IndexConfiguration, Collection<String>> groupedIndexIds) {
if (log.isDebugEnabled()) {
Integer amountOfInstances = groupedIndexIds.values().stream().map(Collection::size).reduce(Integer::sum).orElse(0);
log.debug("Prepared {} instances within {} entities", amountOfInstances, groupedIndexIds.keySet().size());
}
BulkRequest request = new BulkRequest();
for (Map.Entry<IndexConfiguration, Collection<String>> entry : groupedIndexIds.entrySet()) {
IndexConfiguration indexConfiguration = entry.getKey();
for (String indexId : entry.getValue()) {
addDeleteActionToBulkRequest(request, indexConfiguration, indexId);
}
}
BulkResponse bulkResponse = request.requests().isEmpty() ? createNoopBulkResponse() : executeBulkRequest(request);
return IndexResult.create(bulkResponse);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.bulk.BulkRequest in project jmix by jmix-framework.
the class EntityIndexingTest method indexCompositePk.
@Test
@DisplayName("Indexing of entity with Composite primary key")
public void indexCompositePk() {
TestCompositeKey compositeKey = metadata.create(TestCompositeKey.class);
compositeKey.setPkName("pkName");
compositeKey.setPkVersion(1L);
TestCompositePkEntity entity = metadata.create(TestCompositePkEntity.class);
entity.setName("Composite PK entity");
entity.setId(compositeKey);
dataManager.save(entity);
JsonNode jsonNode = TestJsonUtils.readJsonFromFile("indexing/test_content_composite_pk");
TestBulkRequestIndexActionValidationData expectedIndexAction = new TestBulkRequestIndexActionValidationData("search_index_test_compositepkentity", idSerialization.idToString(Id.of(entity)), jsonNode);
TestBulkRequestValidationData expectedData = new TestBulkRequestValidationData(Collections.singletonList(expectedIndexAction), Collections.emptyList());
entityIndexer.index(entity);
List<BulkRequest> bulkRequests = bulkRequestsTracker.getBulkRequests();
TestBulkRequestValidationResult result = TestBulkRequestValidator.validate(Collections.singletonList(expectedData), bulkRequests);
Assert.assertFalse(result.toString(), result.hasFailures());
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.bulk.BulkRequest in project jmix by jmix-framework.
the class EntityIndexingTest method indexDeletedInstanceHardDelete.
@Test
@DisplayName("Indexing already deleted instance (Hard Delete)")
public void indexDeletedInstanceHardDelete() {
TestRootEntityHD instance = metadata.create(TestRootEntityHD.class);
instance.setName("Deleted");
dataManager.save(instance);
dataManager.remove(instance);
entityIndexer.index(instance);
List<BulkRequest> bulkRequests = bulkRequestsTracker.getBulkRequests();
Assert.assertTrue(bulkRequests.isEmpty());
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.bulk.BulkRequest in project jmix by jmix-framework.
the class EntityIndexingTest method indexUuidPk.
@Test
@DisplayName("Indexing of entity with UUID primary key")
public void indexUuidPk() {
TestUuidPkEntity entity = metadata.create(TestUuidPkEntity.class);
entity.setName("UUID PK entity");
dataManager.save(entity);
JsonNode jsonNode = TestJsonUtils.readJsonFromFile("indexing/test_content_uuid_pk");
TestBulkRequestIndexActionValidationData expectedIndexAction = new TestBulkRequestIndexActionValidationData("search_index_test_uuidpkentity", idSerialization.idToString(Id.of(entity)), jsonNode);
TestBulkRequestValidationData expectedData = new TestBulkRequestValidationData(Collections.singletonList(expectedIndexAction), Collections.emptyList());
entityIndexer.index(entity);
List<BulkRequest> bulkRequests = bulkRequestsTracker.getBulkRequests();
TestBulkRequestValidationResult result = TestBulkRequestValidator.validate(Collections.singletonList(expectedData), bulkRequests);
Assert.assertFalse(result.toString(), result.hasFailures());
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.bulk.BulkRequest in project jmix by jmix-framework.
the class EntityIndexingTest method indexWithIndexablePredicate.
@Test
@DisplayName("Indexing instances passed indexable predicate only")
public void indexWithIndexablePredicate() {
TestEntityForPredicate indexableInstance = metadata.create(TestEntityForPredicate.class);
indexableInstance.setName("Indexable");
indexableInstance.setEnumValue(TestEnum.OPEN);
TestEntityForPredicate notIndexableInstance = metadata.create(TestEntityForPredicate.class);
notIndexableInstance.setName("Not Indexable");
notIndexableInstance.setEnumValue(TestEnum.CLOSED);
dataManager.save(indexableInstance, notIndexableInstance);
JsonNode jsonNode = TestJsonUtils.readJsonFromFile("indexing/test_content_entity_for_predicate");
TestBulkRequestIndexActionValidationData expectedIndexAction = new TestBulkRequestIndexActionValidationData("search_index_test_entityforpredicate", idSerialization.idToString(Id.of(indexableInstance)), jsonNode);
TestBulkRequestValidationData expectedData = new TestBulkRequestValidationData(Collections.singletonList(expectedIndexAction), Collections.emptyList());
entityIndexer.indexCollection(Arrays.asList(indexableInstance, notIndexableInstance));
List<BulkRequest> bulkRequests = bulkRequestsTracker.getBulkRequests();
TestBulkRequestValidationResult result = TestBulkRequestValidator.validate(Collections.singletonList(expectedData), bulkRequests);
Assert.assertFalse(result.toString(), result.hasFailures());
}
Aggregations