From 55f9b88ba1d63db75ef9cde3cf94e5c98526ad2f Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 25 Aug 2020 18:09:18 -0700 Subject: significant increase in parse and test coverage --- tests/files/GET_range.txt | 12 ++++++++++ tests/files/GET_search_agg_filter.txt | 28 ++++++++++++++++++++++ tests/files/GET_search_agg_filter_simple.txt | 11 +++++++++ tests/files/GET_search_agg_histogram.txt | 13 ++++++++++ tests/files/GET_search_agg_max.txt | 11 +++++++++ tests/files/GET_search_agg_nested.txt | 16 +++++++++++++ tests/files/GET_search_exists.txt | 8 +++++++ .../files/GET_search_fatcat_preservation_year.txt | 2 ++ tests/files/GET_search_fatcat_scholar_basic.txt | 2 ++ tests/files/GET_search_ids.txt | 8 +++++++ tests/files/GET_search_match_all.txt | 6 +++++ tests/files/GET_search_match_none.txt | 6 +++++ tests/files/GET_search_multi_match_tie.txt | 11 +++++++++ tests/files/GET_search_prefix.txt | 10 ++++++++ tests/files/GET_search_querystring.txt | 14 +++++++++++ tests/files/GET_search_simplequerystring.txt | 10 ++++++++ tests/files/GET_search_term.txt | 11 +++++++++ tests/files/GET_search_term_short.txt | 8 +++++++ tests/files/GET_search_wildcard.txt | 12 ++++++++++ tests/files/POST_search_inner.txt | 17 ------------- tests/files/POST_search_inner.txt.disabled | 17 +++++++++++++ tests/files/scroll/DELETE_scroll_multi.txt | 7 ++++++ tests/parse_es_requests.rs | 4 +++- 23 files changed, 226 insertions(+), 18 deletions(-) create mode 100644 tests/files/GET_range.txt create mode 100644 tests/files/GET_search_agg_filter.txt create mode 100644 tests/files/GET_search_agg_filter_simple.txt create mode 100644 tests/files/GET_search_agg_histogram.txt create mode 100644 tests/files/GET_search_agg_max.txt create mode 100644 tests/files/GET_search_agg_nested.txt create mode 100644 tests/files/GET_search_exists.txt create mode 100644 tests/files/GET_search_fatcat_preservation_year.txt create mode 100644 tests/files/GET_search_fatcat_scholar_basic.txt create mode 100644 tests/files/GET_search_ids.txt create mode 100644 tests/files/GET_search_match_all.txt create mode 100644 tests/files/GET_search_match_none.txt create mode 100644 tests/files/GET_search_multi_match_tie.txt create mode 100644 tests/files/GET_search_prefix.txt create mode 100644 tests/files/GET_search_querystring.txt create mode 100644 tests/files/GET_search_simplequerystring.txt create mode 100644 tests/files/GET_search_term.txt create mode 100644 tests/files/GET_search_term_short.txt create mode 100644 tests/files/GET_search_wildcard.txt delete mode 100644 tests/files/POST_search_inner.txt create mode 100644 tests/files/POST_search_inner.txt.disabled create mode 100644 tests/files/scroll/DELETE_scroll_multi.txt (limited to 'tests') diff --git a/tests/files/GET_range.txt b/tests/files/GET_range.txt new file mode 100644 index 0000000..a5321c3 --- /dev/null +++ b/tests/files/GET_range.txt @@ -0,0 +1,12 @@ +GET /some-index/_search +{ + "query": { + "range": { + "age": { + "gte": 10, + "lte": 20, + "boost": 2.0 + } + } + } +} diff --git a/tests/files/GET_search_agg_filter.txt b/tests/files/GET_search_agg_filter.txt new file mode 100644 index 0000000..538380a --- /dev/null +++ b/tests/files/GET_search_agg_filter.txt @@ -0,0 +1,28 @@ +GET /shirts/_search +{ + "query": { + "bool": { + "filter": { + "term": { "brand": "gucci" } + } + } + }, + "aggs": { + "colors": { + "terms": { "field": "color" } + }, + "color_red": { + "filter": { + "term": { "color": "red" } + }, + "aggs": { + "models": { + "terms": { "field": "model" } + } + } + } + }, + "post_filter": { + "term": { "color": "red" } + } +} diff --git a/tests/files/GET_search_agg_filter_simple.txt b/tests/files/GET_search_agg_filter_simple.txt new file mode 100644 index 0000000..71a9777 --- /dev/null +++ b/tests/files/GET_search_agg_filter_simple.txt @@ -0,0 +1,11 @@ +POST /sales/_search?size=0 +{ + "aggs": { + "t_shirts": { + "filter": { "term": { "type": "t-shirt" } }, + "aggs": { + "avg_price": { "avg": { "field": "price" } } + } + } + } +} diff --git a/tests/files/GET_search_agg_histogram.txt b/tests/files/GET_search_agg_histogram.txt new file mode 100644 index 0000000..4689ad1 --- /dev/null +++ b/tests/files/GET_search_agg_histogram.txt @@ -0,0 +1,13 @@ +POST /sales/_search?size=0 +{ + "aggs": { + "quantity": { + "histogram": { + "field": "quantity", + "interval": 10, + "keyed": true, + "missing": 0 + } + } + } +} diff --git a/tests/files/GET_search_agg_max.txt b/tests/files/GET_search_agg_max.txt new file mode 100644 index 0000000..1377afc --- /dev/null +++ b/tests/files/GET_search_agg_max.txt @@ -0,0 +1,11 @@ +POST /sales/_search +{ + "aggs" : { + "grade_max" : { + "max" : { + "field" : "grade", + "missing": 10 + } + } + } +} diff --git a/tests/files/GET_search_agg_nested.txt b/tests/files/GET_search_agg_nested.txt new file mode 100644 index 0000000..8e5d1c1 --- /dev/null +++ b/tests/files/GET_search_agg_nested.txt @@ -0,0 +1,16 @@ +GET /products/_search +{ + "query": { + "match": { "name": "led tv" } + }, + "aggs": { + "resellers": { + "nested": { + "path": "resellers" + }, + "aggs": { + "min_price": { "min": { "field": "resellers.price" } } + } + } + } +} diff --git a/tests/files/GET_search_exists.txt b/tests/files/GET_search_exists.txt new file mode 100644 index 0000000..fe7d722 --- /dev/null +++ b/tests/files/GET_search_exists.txt @@ -0,0 +1,8 @@ +GET /some-index/_search +{ + "query": { + "exists": { + "field": "user" + } + } +} diff --git a/tests/files/GET_search_fatcat_preservation_year.txt b/tests/files/GET_search_fatcat_preservation_year.txt new file mode 100644 index 0000000..539677b --- /dev/null +++ b/tests/files/GET_search_fatcat_preservation_year.txt @@ -0,0 +1,2 @@ +GET /fatcat_release/_search +{"query": {"bool": {"filter": [{"term": {"container_id": "yh4zdhfsobdolesogv6czydwqi"}}, {"range": {"release_year": {"gte": 1771, "lte": 2020}}}]}}, "aggs": {"year_preservation": {"composite": {"size": 1500, "sources": [{"year": {"histogram": {"field": "release_year", "interval": 1}}}, {"preservation": {"terms": {"field": "preservation"}}}]}}}, "from": 0, "size": 0} diff --git a/tests/files/GET_search_fatcat_scholar_basic.txt b/tests/files/GET_search_fatcat_scholar_basic.txt new file mode 100644 index 0000000..c60e62f --- /dev/null +++ b/tests/files/GET_search_fatcat_scholar_basic.txt @@ -0,0 +1,2 @@ +GET /scholar_fulltext/_search +{"query": {"bool": {"filter": [{"terms": {"type": ["article-journal", "paper-conference", "chapter"]}}, {"terms": {"access_type": ["wayback", "ia_file", "ia_sim"]}}], "must": [{"boosting": {"positive": {"bool": {"must": [{"query_string": {"query": "coffee", "default_operator": "AND", "analyze_wildcard": true, "allow_leading_wildcard": false, "lenient": true, "quote_field_suffix": ".exact", "fields": ["title^5", "biblio_all^3", "abstracts.body^2", "fulltext.body", "everything"]}}], "should": [{"terms": {"access_type": ["ia_sim", "ia_file", "wayback"]}}]}}, "negative": {"bool": {"should": [{"bool": {"must_not": [{"exists": {"field": "title"}}]}}, {"bool": {"must_not": [{"exists": {"field": "year"}}]}}, {"bool": {"must_not": [{"exists": {"field": "type"}}]}}, {"bool": {"must_not": [{"exists": {"field": "stage"}}]}}, {"bool": {"must_not": [{"exists": {"field": "biblio.container_ident"}}]}}]}}, "negative_boost": 0.5}}]}}, "collapse": {"field": "collapse_key", "inner_hits": {"name": "more_pages", "size": 0}}, "from": 0, "size": 15, "highlight": {"fields": {"abstracts.body": {"number_of_fragments": 2, "fragment_size": 300}, "fulltext.body": {"number_of_fragments": 2, "fragment_size": 300}, "fulltext.acknowledgment": {"number_of_fragments": 2, "fragment_size": 300}, "fulltext.annex": {"number_of_fragments": 2, "fragment_size": 300}}}} diff --git a/tests/files/GET_search_ids.txt b/tests/files/GET_search_ids.txt new file mode 100644 index 0000000..f22c8b1 --- /dev/null +++ b/tests/files/GET_search_ids.txt @@ -0,0 +1,8 @@ +GET /some-index/_search +{ + "query": { + "ids" : { + "values" : ["1", "4", "100"] + } + } +} diff --git a/tests/files/GET_search_match_all.txt b/tests/files/GET_search_match_all.txt new file mode 100644 index 0000000..1d9622c --- /dev/null +++ b/tests/files/GET_search_match_all.txt @@ -0,0 +1,6 @@ +GET /some-index/_search +{ + "query": { + "match_all": { "boost" : 1.2 } + } +} diff --git a/tests/files/GET_search_match_none.txt b/tests/files/GET_search_match_none.txt new file mode 100644 index 0000000..12f50fc --- /dev/null +++ b/tests/files/GET_search_match_none.txt @@ -0,0 +1,6 @@ +GET /some-index/_search +{ + "query": { + "match_none": {} + } +} diff --git a/tests/files/GET_search_multi_match_tie.txt b/tests/files/GET_search_multi_match_tie.txt new file mode 100644 index 0000000..54f71db --- /dev/null +++ b/tests/files/GET_search_multi_match_tie.txt @@ -0,0 +1,11 @@ +GET /some-index/_search +{ + "query": { + "multi_match" : { + "query": "brown fox", + "type": "best_fields", + "fields": [ "subject", "message" ], + "tie_breaker": 0.3 + } + } +} diff --git a/tests/files/GET_search_prefix.txt b/tests/files/GET_search_prefix.txt new file mode 100644 index 0000000..3e35556 --- /dev/null +++ b/tests/files/GET_search_prefix.txt @@ -0,0 +1,10 @@ +GET /some-index/_search +{ + "query": { + "prefix": { + "user.id": { + "value": "ki" + } + } + } +} diff --git a/tests/files/GET_search_querystring.txt b/tests/files/GET_search_querystring.txt new file mode 100644 index 0000000..1c6e31e --- /dev/null +++ b/tests/files/GET_search_querystring.txt @@ -0,0 +1,14 @@ +GET /some-index/_search +{ + "query": { + "query_string": { + "fields": [ + "title", + "content" + ], + "query": "this OR that OR thus", + "type": "cross_fields", + "minimum_should_match": 2 + } + } +} diff --git a/tests/files/GET_search_simplequerystring.txt b/tests/files/GET_search_simplequerystring.txt new file mode 100644 index 0000000..2ae5507 --- /dev/null +++ b/tests/files/GET_search_simplequerystring.txt @@ -0,0 +1,10 @@ +GET /some-index/_search +{ + "query": { + "simple_query_string" : { + "query": "\"fried eggs\" +(eggplant | potato) -frittata", + "fields": ["title^5", "body"], + "default_operator": "and" + } + } +} diff --git a/tests/files/GET_search_term.txt b/tests/files/GET_search_term.txt new file mode 100644 index 0000000..149587f --- /dev/null +++ b/tests/files/GET_search_term.txt @@ -0,0 +1,11 @@ +GET /some-value/_search +{ + "query": { + "term": { + "user.id": { + "value": "kimchy", + "boost": 1.0 + } + } + } +} diff --git a/tests/files/GET_search_term_short.txt b/tests/files/GET_search_term_short.txt new file mode 100644 index 0000000..937a7b5 --- /dev/null +++ b/tests/files/GET_search_term_short.txt @@ -0,0 +1,8 @@ +GET /my-index-000001/_search?pretty=true +{ + "query": { + "match": { + "full_text": "Quick Brown Foxes!" + } + } +} diff --git a/tests/files/GET_search_wildcard.txt b/tests/files/GET_search_wildcard.txt new file mode 100644 index 0000000..6eb199d --- /dev/null +++ b/tests/files/GET_search_wildcard.txt @@ -0,0 +1,12 @@ +GET /some-index/_search +{ + "query": { + "wildcard": { + "user.id": { + "value": "ki*y", + "boost": 1.0, + "rewrite": "constant_score" + } + } + } +} diff --git a/tests/files/POST_search_inner.txt b/tests/files/POST_search_inner.txt deleted file mode 100644 index 56c5acc..0000000 --- a/tests/files/POST_search_inner.txt +++ /dev/null @@ -1,17 +0,0 @@ -POST /test/_search -{ - "query": { - "nested": { - "path": "comments", - "query": { - "match": { "comments.text": "words" } - }, - "inner_hits": { - "_source": false, - "docvalue_fields": [ - "comments.text.keyword" - ] - } - } - } -} diff --git a/tests/files/POST_search_inner.txt.disabled b/tests/files/POST_search_inner.txt.disabled new file mode 100644 index 0000000..56c5acc --- /dev/null +++ b/tests/files/POST_search_inner.txt.disabled @@ -0,0 +1,17 @@ +POST /test/_search +{ + "query": { + "nested": { + "path": "comments", + "query": { + "match": { "comments.text": "words" } + }, + "inner_hits": { + "_source": false, + "docvalue_fields": [ + "comments.text.keyword" + ] + } + } + } +} diff --git a/tests/files/scroll/DELETE_scroll_multi.txt b/tests/files/scroll/DELETE_scroll_multi.txt new file mode 100644 index 0000000..43ba8e2 --- /dev/null +++ b/tests/files/scroll/DELETE_scroll_multi.txt @@ -0,0 +1,7 @@ +DELETE /_search/scroll +{ + "scroll_id" : [ + "DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==", + "DnF1ZXJ5VGhlbkZldGNoBQAAAAAAAAABFmtSWWRRWUJrU2o2ZExpSGJCVmQxYUEAAAAAAAAAAxZrUllkUVlCa1NqNmRMaUhiQlZkMWFBAAAAAAAAAAIWa1JZZFFZQmtTajZkTGlIYkJWZDFhQQAAAAAAAAAFFmtSWWRRWUJrU2o2ZExpSGJCVmQxYUEAAAAAAAAABBZrUllkUVlCa1NqNmRMaUhiQlZkMWFB" + ] +} diff --git a/tests/parse_es_requests.rs b/tests/parse_es_requests.rs index d453392..8e84148 100644 --- a/tests/parse_es_requests.rs +++ b/tests/parse_es_requests.rs @@ -36,7 +36,9 @@ fn parse_search_bodies() { if let Some(body) = parts.body { println!("parsing: {}", path.display()); println!("BODY: {}", body); - let _parsed: SearchBody = serde_json::from_str(&body).unwrap(); + let parsed: SearchBody = serde_json::from_str(&body).unwrap(); + let raw_val: serde_json::Value = serde_json::from_str(&body).unwrap(); + assert_eq!(raw_val, serde_json::to_value(parsed).unwrap()); } } } -- cgit v1.2.3