diff --git a/tests/search/grouping_adv/answers/istrue-1.json b/tests/search/grouping_adv/answers/istrue-1.json new file mode 100644 index 000000000..4f5551da6 --- /dev/null +++ b/tests/search/grouping_adv/answers/istrue-1.json @@ -0,0 +1,59 @@ +{ + "root": { + "id": "toplevel", + "relevance": 1.0, + "fields": { + "totalCount": 28 + }, + "coverage": { + "coverage": 100, + "documents": 28, + "full": true, + "nodes": 2, + "results": 1, + "resultsFull": 1 + }, + "children": [ + { + "id": "group:root:0", + "relevance": 1.0, + "continuation": { + "this": "" + }, + "children": [ + { + "id": "grouplist:a", + "relevance": 1.0, + "label": "a", + "children": [ + { + "id": "group:string:a1", + "relevance": 10977.31338339293, + "value": "a1", + "fields": { + "count()": 5 + } + }, + { + "id": "group:string:a3", + "relevance": 10011.709521325834, + "value": "a3", + "fields": { + "count()": 4 + } + }, + { + "id": "group:string:a2", + "relevance": 9998.214537458838, + "value": "a2", + "fields": { + "count()": 3 + } + } + ] + } + ] + } + ] + } +} diff --git a/tests/search/grouping_adv/answers/istrue-2.json b/tests/search/grouping_adv/answers/istrue-2.json new file mode 100644 index 000000000..c47d5f5af --- /dev/null +++ b/tests/search/grouping_adv/answers/istrue-2.json @@ -0,0 +1,43 @@ +{ + "root": { + "id": "toplevel", + "relevance": 1.0, + "fields": { + "totalCount": 28 + }, + "coverage": { + "coverage": 100, + "documents": 28, + "full": true, + "nodes": 2, + "results": 1, + "resultsFull": 1 + }, + "children": [ + { + "id": "group:root:0", + "relevance": 1.0, + "continuation": { + "this": "" + }, + "children": [ + { + "id": "grouplist:boool", + "relevance": 1.0, + "label": "boool", + "children": [ + { + "id": "group:bool:true", + "relevance": 10977.31338339293, + "value": "true", + "fields": { + "count()": 12 + } + } + ] + } + ] + } + ] + } +} diff --git a/tests/search/grouping_adv/answers/istrue-3.json b/tests/search/grouping_adv/answers/istrue-3.json new file mode 100644 index 000000000..4fed3250b --- /dev/null +++ b/tests/search/grouping_adv/answers/istrue-3.json @@ -0,0 +1,43 @@ +{ + "root": { + "id": "toplevel", + "relevance": 1.0, + "fields": { + "totalCount": 28 + }, + "coverage": { + "coverage": 100, + "documents": 28, + "full": true, + "nodes": 2, + "results": 1, + "resultsFull": 1 + }, + "children": [ + { + "id": "group:root:0", + "relevance": 1.0, + "continuation": { + "this": "" + }, + "children": [ + { + "id": "grouplist:a", + "relevance": 1.0, + "label": "a", + "children": [ + { + "id": "group:string:a1", + "relevance": 10977.31338339293, + "value": "a1", + "fields": { + "count()": 5 + } + } + ] + } + ] + } + ] + } +} diff --git a/tests/search/grouping_adv/answers/istrue-4.json b/tests/search/grouping_adv/answers/istrue-4.json new file mode 100644 index 000000000..8f874ffba --- /dev/null +++ b/tests/search/grouping_adv/answers/istrue-4.json @@ -0,0 +1,59 @@ +{ + "root": { + "id": "toplevel", + "relevance": 1.0, + "fields": { + "totalCount": 28 + }, + "coverage": { + "coverage": 100, + "documents": 28, + "full": true, + "nodes": 2, + "results": 1, + "resultsFull": 1 + }, + "children": [ + { + "id": "group:root:0", + "relevance": 1.0, + "continuation": { + "this": "" + }, + "children": [ + { + "id": "grouplist:a", + "relevance": 1.0, + "label": "a", + "children": [ + { + "id": "group:string:a1", + "relevance": 12111.719438207627, + "value": "a1", + "fields": { + "count()": 5 + } + }, + { + "id": "group:string:a2", + "relevance": 11111.709477840308, + "value": "a2", + "fields": { + "count()": 6 + } + }, + { + "id": "group:string:a3", + "relevance": 6985.517516649399, + "value": "a3", + "fields": { + "count()": 5 + } + } + ] + } + ] + } + ] + } +} diff --git a/tests/search/grouping_adv/grouping_base.rb b/tests/search/grouping_adv/grouping_base.rb index feb8744af..96d1041f5 100644 --- a/tests/search/grouping_adv/grouping_base.rb +++ b/tests/search/grouping_adv/grouping_base.rb @@ -21,6 +21,7 @@ def querytest_common wait_for_hitcount('query=test&streaming.selection=true', 28, 10) querytest_filter + querytest_istrue_error_handling # Test quantiles check_query('all(group(boool) each(output(quantiles([0.1], f))))', 'quantile-1', 40) @@ -308,6 +309,11 @@ def querytest_filter check_query('all(group(a) each(group(b) filter(regex("c1", c)) each(output(count()))))', 'filter-4') check_query('all(group(a) filter(regex("c2", c)) each(group(b) each(output(count()))))', 'filter-5') check_query('all(group(a) filter(regex("a1", a)) each(group(b) filter(regex("b1", b)) each(output(count()))))', 'filter-6') + + check_query('all(group(a) filter(istrue(boool)) each(output(count())))', 'istrue-1') + check_query('all(group(boool) filter(istrue(boool)) each(output(count())))', 'istrue-2') + check_query('all(group(a) filter(istrue(boool) and regex("^a1$", a)) each(output(count())))', 'istrue-3') + check_query('all(group(a) filter(not istrue(boool)) each(output(count())))', 'istrue-4') end # Tests that are known to fail @@ -315,6 +321,14 @@ def querytest_failing_common wait_for_hitcount('query=test&streaming.selection=true', 28, 10) end + def querytest_istrue_error_handling + result = search('/search/?hits=0&query=sddocname:test&select=all(group(a) filter(istrue(n)) each(output(count())))&restrict=test&streaming.selection=true') + puts result + assert(result.json['root']['errors'], "Expected error when using istrue with non-boolean field") + error_message = result.json['root']['errors'][0]['message'] + assert_match(/boolean input|filter error/i, error_message, "Expected error message about boolean input or filter error, got: #{error_message}") + end + def querytest_global_max check_query('all(group(a)max(inf)each(max(inf)each(output(summary()))))', 'global-max-1', DEFAULT_TIMEOUT, false) check_query('all(group(a)max(inf)each(each(output(summary()))))', 'global-max-2', DEFAULT_TIMEOUT, false)