Skip to content

Instantly share code, notes, and snippets.

@lancewf
Last active September 23, 2020 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lancewf/be7bb66bce4c57f22871bc377b4db4e1 to your computer and use it in GitHub Desktop.
Save lancewf/be7bb66bce4c57f22871bc377b4db4e1 to your computer and use it in GitHub Desktop.
compliance suggestions ES7 vs ES6
curl -X POST -f --insecure -H "api-token: $(get_admin_token)" "https://localhost/api/v0/compliance/reporting/suggestions" -d '{"type": "control", "text": "Profile 2 - Control 1", "size": 3}' | jq
ES7 request query
{
"_source":false,
"aggregations":{
"profiles":{
"aggregations":{
"controls_filter":{
"aggregations":{
"controls":{
"aggregations":{
"titles":{
"aggregations":{
"ids":{
"terms":{
"field":"profiles.controls.id",
"order":[
{
"_count":"desc"
}
],
"size":3
}
}
},
"terms":{
"field":"profiles.controls.title",
"order":[
{
"_count":"desc"
}
],
"size":3
}
}
},
"filter":{
"bool":{
"must":{
"match":{
"profiles.controls.title.engram":{
"operator":"or",
"query":"Profile 2 - Control 1"
}
}
},
"should":[
{
"match":{
"profiles.controls.title.engram":{
"operator":"and",
"query":"Profile 2 - Control 1"
}
}
},
{
"term":{
"profiles.controls.title":{
"boost":100,
"value":"Profile 2 - Control 1"
}
}
},
{
"prefix":{
"profiles.controls.title":{
"boost":100,
"value":"Profile 2 - Control 1"
}
}
}
]
}
}
}
},
"nested":{
"path":"profiles.controls"
}
}
},
"nested":{
"path":"profiles"
}
}
},
"query":{
"bool":{
"must":{
"terms":{
"daily_latest":[
true
]
}
}
}
},
"size":0
}
response
{
"took": 54,
"timed_out": false,
"_shards": {
"total": 30,
"successful": 30,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 11,
"relation": "eq"
},
"max_score": null,
"hits": []
},
"aggregations": {
"profiles": {
"doc_count": 22,
"controls_filter": {
"doc_count": 171,
"controls": {
"doc_count": 57,
"titles": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 36,
"buckets": [
{
"key": "Check Apache config file owner, group and permissions.",
"doc_count": 7,
"ids": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "apache-05",
"doc_count": 7
}
]
}
},
{
"key": "Check Apache config folder owner, group and permissions.",
"doc_count": 7,
"ids": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "apache-04",
"doc_count": 7
}
]
}
},
{
"key": "Disable Apache’s follows Symbolic Links for directories in alias.conf",
"doc_count": 7,
"ids": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "apache-11",
"doc_count": 7
}
]
}
}
]
}
}
}
}
}
}
ES6 request query
The only difference I see is that the size is set to 10 and not 3.
{
"_source":false,
"aggregations":{
"profiles":{
"aggregations":{
"controls_filter":{
"aggregations":{
"controls":{
"aggregations":{
"titles":{
"aggregations":{
"ids":{
"terms":{
"field":"profiles.controls.id",
"order":[
{
"_count":"desc"
}
],
"size":10
}
}
},
"terms":{
"field":"profiles.controls.title",
"order":[
{
"_count":"desc"
}
],
"size":10
}
}
},
"filter":{
"bool":{
"must":{
"match":{
"profiles.controls.title.engram":{
"operator":"or",
"query":"Profile 2 - Control 1"
}
}
},
"should":[
{
"match":{
"profiles.controls.title.engram":{
"operator":"and",
"query":"Profile 2 - Control 1"
}
}
},
{
"term":{
"profiles.controls.title":{
"boost":100,
"value":"Profile 2 - Control 1"
}
}
},
{
"prefix":{
"profiles.controls.title":{
"boost":100,
"value":"Profile 2 - Control 1"
}
}
}
]
}
}
}
},
"nested":{
"path":"profiles.controls"
}
}
},
"nested":{
"path":"profiles"
}
}
},
"query":{
"bool":{
"must":[
{
"type":{
"value":"_doc"
}
},
{
"terms":{
"daily_latest":[
true
]
}
}
]
}
},
"size":0
}
response
{
"took": 120,
"timed_out": false,
"_shards": {
"total": 30,
"successful": 30,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 11,
"max_score": 0,
"hits": []
},
"aggregations": {
"profiles": {
"doc_count": 22,
"controls_filter": {
"doc_count": 171,
"controls": {
"doc_count": 7,
"titles": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "Profile 2 - Control 1",
"doc_count": 2,
"ids": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "pro2-con1",
"doc_count": 2
}
]
}
},
{
"key": "Profile 1 - Control 1",
"doc_count": 1,
"ids": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "pro1-con1",
"doc_count": 1
}
]
}
},
{
"key": "Profile 1 - Control 2",
"doc_count": 1,
"ids": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "pro1-con2",
"doc_count": 1
}
]
}
},
{
"key": "Profile 1 - Control 3",
"doc_count": 1,
"ids": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "pro1-con3",
"doc_count": 1
}
]
}
},
{
"key": "Profile 1 - Control 4",
"doc_count": 1,
"ids": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "pro1-con4",
"doc_count": 1
}
]
}
},
{
"key": "Profile 1 - Control 5",
"doc_count": 1,
"ids": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "pro1-con5",
"doc_count": 1
}
]
}
}
]
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment