mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-05 20:48:22 +00:00
Remove last remnants of bucket/record parent/child relationship (elastic/elasticsearch#387)
The majority of this change was done in PR elastic/elasticsearch#300 - this is just a tidy-up Original commit: elastic/x-pack-elasticsearch@c9886f0592
This commit is contained in:
parent
25fb2a4b24
commit
2ef240c20b
@ -118,10 +118,6 @@ public class ElasticsearchBulkDeleter implements JobDataDeleter {
|
||||
.setIndex(JobResultsPersister.getJobIndexName(jobId))
|
||||
.setType(hit.getType())
|
||||
.setId(hit.getId());
|
||||
SearchHitField parentField = hit.field(ElasticsearchMappings.PARENT);
|
||||
if (parentField != null) {
|
||||
deleteRequest.setParent(parentField.getValue().toString());
|
||||
}
|
||||
bulkRequestBuilder.add(deleteRequest);
|
||||
}
|
||||
|
||||
|
@ -715,7 +715,7 @@ public class ElasticsearchJobProvider implements JobProvider
|
||||
|
||||
|
||||
/**
|
||||
* The returned records have the parent bucket id set.
|
||||
* The returned records have their id set.
|
||||
*/
|
||||
private QueryPage<AnomalyRecord> records(String jobId, int from, int size,
|
||||
QueryBuilder recordFilter, FieldSortBuilder sb, List<String> secondarySort,
|
||||
@ -761,7 +761,7 @@ public class ElasticsearchJobProvider implements JobProvider
|
||||
}
|
||||
AnomalyRecord record = AnomalyRecord.PARSER.apply(parser, () -> parseFieldMatcher);
|
||||
|
||||
// set the ID and parent ID
|
||||
// set the ID
|
||||
record.setId(hit.getId());
|
||||
results.add(record);
|
||||
}
|
||||
|
@ -61,7 +61,6 @@ public class ElasticsearchMappings {
|
||||
static final String INCLUDE_IN_ALL = "include_in_all";
|
||||
static final String NESTED = "nested";
|
||||
static final String COPY_TO = "copy_to";
|
||||
static final String PARENT = "_parent";
|
||||
static final String PROPERTIES = "properties";
|
||||
static final String TYPE = "type";
|
||||
static final String DYNAMIC = "dynamic";
|
||||
@ -370,8 +369,6 @@ public class ElasticsearchMappings {
|
||||
}
|
||||
|
||||
/**
|
||||
* Records have a _parent mapping to a {@linkplain org.elasticsearch.xpack.prelert.job.results.Bucket}.
|
||||
*
|
||||
* @param termFieldNames Optionally, other field names to include in the
|
||||
* mappings. Pass <code>null</code> if not required.
|
||||
*/
|
||||
|
@ -46,9 +46,7 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
* records. The anomaly score of the bucket may not match the summed score of
|
||||
* all the records as all the records may not have been outputted for the
|
||||
* bucket.
|
||||
* <h2>Anomaly Record</h2> In Elasticsearch records have a parent <-<
|
||||
* child relationship with buckets and should only exist is relation to a parent
|
||||
* bucket. Each record was generated by a detector which can be identified via
|
||||
* <h2>Anomaly Record</h2> Each record was generated by a detector which can be identified via
|
||||
* the detectorIndex field.
|
||||
* <h2>Detector</h2> The Job has a fixed number of detectors but there may not
|
||||
* be output for every detector in each bucket. <br>
|
||||
|
@ -1020,7 +1020,6 @@ public class ElasticsearchJobProviderTests extends ESTestCase {
|
||||
|
||||
for (Map<String, Object> map : source) {
|
||||
SearchHit hit = mock(SearchHit.class);
|
||||
// remove the _parent from the field we use for _source
|
||||
Map<String, Object> _source = new HashMap<>(map);
|
||||
when(hit.getSourceRef()).thenReturn(XContentFactory.jsonBuilder().map(_source).bytes());
|
||||
when(hit.getId()).thenReturn(String.valueOf(map.hashCode()));
|
||||
|
@ -80,7 +80,6 @@ public class ElasticsearchMappingsTests extends ESTestCase {
|
||||
overridden.add(ElasticsearchMappings.INDEX);
|
||||
overridden.add(ElasticsearchMappings.NESTED);
|
||||
overridden.add(ElasticsearchMappings.NO);
|
||||
overridden.add(ElasticsearchMappings.PARENT);
|
||||
overridden.add(ElasticsearchMappings.PROPERTIES);
|
||||
overridden.add(ElasticsearchMappings.TYPE);
|
||||
overridden.add(ElasticsearchMappings.WHITESPACE);
|
||||
|
@ -296,7 +296,6 @@ public class MockClientBuilder {
|
||||
|
||||
when(client.prepareIndex(eq(index), any(), any())).thenReturn(builder);
|
||||
when(builder.setSource(eq(source))).thenReturn(builder);
|
||||
when(builder.setParent(any(String.class))).thenReturn(builder);
|
||||
when(builder.setRefreshPolicy(eq(RefreshPolicy.IMMEDIATE))).thenReturn(builder);
|
||||
when(builder.execute()).thenReturn(actionFuture);
|
||||
when(actionFuture.actionGet()).thenReturn(mock(IndexResponse.class));
|
||||
@ -311,7 +310,6 @@ public class MockClientBuilder {
|
||||
when(client.prepareIndex(eq(index), any(), any())).thenReturn(builder);
|
||||
when(builder.setSource(getSource.capture())).thenReturn(builder);
|
||||
when(builder.setRefreshPolicy(eq(RefreshPolicy.IMMEDIATE))).thenReturn(builder);
|
||||
when(builder.setParent(any(String.class))).thenReturn(builder);
|
||||
when(builder.execute()).thenReturn(actionFuture);
|
||||
when(actionFuture.actionGet()).thenReturn(mock(IndexResponse.class));
|
||||
return this;
|
||||
@ -327,7 +325,6 @@ public class MockClientBuilder {
|
||||
when(client.prepareIndex(eq(index), eq(type))).thenReturn(builder);
|
||||
when(client.prepareIndex(eq(index), eq(type), any(String.class))).thenReturn(builder);
|
||||
when(builder.setSource(getSource.capture())).thenReturn(builder);
|
||||
when(builder.setParent(any(String.class))).thenReturn(builder);
|
||||
when(builder.setRefreshPolicy(eq(RefreshPolicy.IMMEDIATE))).thenReturn(builder);
|
||||
when(builder.execute()).thenReturn(actionFuture);
|
||||
when(actionFuture.actionGet()).thenReturn(response);
|
||||
|
Loading…
x
Reference in New Issue
Block a user