mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-16 09:54:55 +00:00
Add job Id to custom all field (elastic/elasticsearch#598)
* Add job Id to custom all field * Add yaml test for searching fields copied to custom all Original commit: elastic/x-pack-elasticsearch@419189460f
This commit is contained in:
parent
68b8ce40fd
commit
dee7412044
@ -138,6 +138,7 @@ public class ElasticsearchMappings {
|
||||
.endObject()
|
||||
.startObject(Job.ID.getPreferredName())
|
||||
.field(TYPE, KEYWORD)
|
||||
.field(COPY_TO, ALL_FIELD_VALUES)
|
||||
.endObject()
|
||||
.startObject(Bucket.TIMESTAMP.getPreferredName())
|
||||
.field(TYPE, DATE)
|
||||
|
@ -0,0 +1,133 @@
|
||||
setup:
|
||||
- do:
|
||||
xpack.prelert.put_job:
|
||||
body: >
|
||||
{
|
||||
"job_id": "custom-all-test-1",
|
||||
"description":"Job for testing custom all field",
|
||||
"analysis_config" : {
|
||||
"detectors" :[{"function":"metric","field_name":"responsetime","by_field_name":"airline"}]
|
||||
}
|
||||
}
|
||||
- do:
|
||||
xpack.prelert.put_job:
|
||||
body: >
|
||||
{
|
||||
"job_id": "custom-all-test-2",
|
||||
"description":"Job for testing custom all field",
|
||||
"analysis_config" : {
|
||||
"detectors" :[{"function":"metric","field_name":"responsetime","by_field_name":"airline"}]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- do:
|
||||
index:
|
||||
index: prelertresults-custom-all-test-1
|
||||
type: result
|
||||
id: custom_all_1464739200000_1_1
|
||||
body:
|
||||
{
|
||||
"job_id": "custom-all-test-1",
|
||||
"result_type": "record",
|
||||
"timestamp": "2016-06-01T00:00:00Z",
|
||||
"anomaly_score": 60.0,
|
||||
"bucket_span": 1,
|
||||
"by_field_value": "A by field",
|
||||
"partition_field_value": "A partition field",
|
||||
"over_field_value": "An over field",
|
||||
"influencer_field_name": "An influencer field",
|
||||
"causes": [{
|
||||
"by_field_value": "Cause by field",
|
||||
"partition_field_value": "Cause partition field",
|
||||
"over_field_value": "Cause over field",
|
||||
"correlated_by_field_value": "Cause correlated by field"
|
||||
}]
|
||||
}
|
||||
|
||||
- do:
|
||||
index:
|
||||
index: prelertresults-custom-all-test-2
|
||||
type: result
|
||||
id: custom_all_1464739200000_1_2
|
||||
body:
|
||||
{
|
||||
"job_id": "custom-all-test-2",
|
||||
"result_type": "record",
|
||||
"timestamp": "2016-06-01T00:00:00Z",
|
||||
"bucket_span": 1,
|
||||
"by_field_value": "A by field"
|
||||
}
|
||||
|
||||
- do:
|
||||
indices.refresh:
|
||||
index: [prelertresults-custom-all-test-1, prelertresults-custom-all-test-2]
|
||||
|
||||
---
|
||||
"Test querying custom all field":
|
||||
|
||||
- do:
|
||||
search:
|
||||
index: prelertresults-custom-all-test-1
|
||||
body: { query: { query_string: { query: "A by field" } } }
|
||||
- match: { hits.total: 1 }
|
||||
|
||||
- do:
|
||||
search:
|
||||
index: prelertresults-custom-all-test-1
|
||||
body: { query: { query_string: { query: "A partition field" } } }
|
||||
- match: { hits.total: 1 }
|
||||
|
||||
- do:
|
||||
search:
|
||||
index: prelertresults-custom-all-test-1
|
||||
body: { query: { query_string: { query: "An over field" } } }
|
||||
- match: { hits.total: 1 }
|
||||
|
||||
- do:
|
||||
search:
|
||||
index: prelertresults-custom-all-test-1
|
||||
body: { query: { query_string: { query: "An influencer field" } } }
|
||||
- match: { hits.total: 1 }
|
||||
|
||||
- do:
|
||||
search:
|
||||
index: prelertresults-custom-all-test-1
|
||||
body: { query: { query_string: { query: "Cause by field" } } }
|
||||
- match: { hits.total: 1 }
|
||||
|
||||
- do:
|
||||
search:
|
||||
index: prelertresults-custom-all-test-1
|
||||
body: { query: { query_string: { query: "Cause partition field" } } }
|
||||
- match: { hits.total: 1 }
|
||||
|
||||
- do:
|
||||
search:
|
||||
index: prelertresults-custom-all-test-1
|
||||
body: { query: { query_string: { query: "Cause over field" } } }
|
||||
- match: { hits.total: 1 }
|
||||
|
||||
- do:
|
||||
search:
|
||||
index: prelertresults-custom-all-test-1
|
||||
body: { query: { query_string: { query: "Cause correlated by field" } } }
|
||||
- match: { hits.total: 1 }
|
||||
|
||||
- do:
|
||||
search:
|
||||
index: prelertresults-custom-all-test-1
|
||||
body: { query: { query_string: { query: "custom-all-test-1" } } }
|
||||
- match: { hits.total: 1 }
|
||||
|
||||
---
|
||||
"Test wildcard job id":
|
||||
|
||||
- do:
|
||||
search:
|
||||
body: { query: { bool: { must: [
|
||||
{ query_string: { query: "_type:result AND result_type:record"} },
|
||||
{ query_string: { query: "A by field" } },
|
||||
{ query_string: { query: "job_id:*" } }
|
||||
] } } }
|
||||
- match: { hits.total: 2 }
|
Loading…
x
Reference in New Issue
Block a user