From 9b85d1cced24ea2d72e6a4920120157f05581bad Mon Sep 17 00:00:00 2001 From: Stas Klinov Date: Wed, 3 Jul 2024 14:27:25 +0200 Subject: [PATCH] fixed sort property depends on the properties order at the aggs node; added cases to test 334; fixed #2364 --- src/sphinxjsonquery.cpp | 200 ++++++++++++++++++++++------------------ test/test_334/model.bin | 4 +- test/test_334/test.xml | 7 ++ 3 files changed, 118 insertions(+), 93 deletions(-) diff --git a/src/sphinxjsonquery.cpp b/src/sphinxjsonquery.cpp index 8e0aabbc68..57264ea25f 100644 --- a/src/sphinxjsonquery.cpp +++ b/src/sphinxjsonquery.cpp @@ -3605,125 +3605,143 @@ static bool ParseAggrComposite ( const JsonObj_c & tBucket, JsonAggr_t & tAggr, return true; } -static bool AddSubAggregate ( const JsonObj_c & tAggs, bool bRoot, CSphVector & dParentItems, CSphString & sError ) +static bool ParseAggsNode ( const JsonObj_c & tBucket, const JsonObj_c & tJsonItem, bool bRoot, JsonAggr_t & tItem, CSphString & sError ) { - if ( bRoot && tAggs.begin().Empty() ) + if ( !tBucket.IsObj() ) { - JsonAggr_t & tCount = dParentItems.Add(); - tCount.m_eAggrFunc = Aggr_e::COUNT; - tCount.m_iSize = 1; - return true; + sError.SetSprintf ( R"("aggs" bucket '%s' should be an object)", tItem.m_sBucketName.cstr() ); + return false; } - CSphString sWarning; - JsonQuery_c tTmpQuery; + if ( !StrEq ( tBucket.Name(), "composite" ) && !tBucket.FetchStrItem ( tItem.m_sCol, "field", sError, false ) ) + return false; - for ( const auto & tJsonItem : tAggs ) + tBucket.FetchIntItem ( tItem.m_iSize, "size", sError, true ); + int iShardSize = 0; + tBucket.FetchIntItem ( iShardSize, "shard_size", sError, true ); + tItem.m_iSize = Max ( tItem.m_iSize, iShardSize ); // FIXME!!! use (size * 1.5 + 10) for shard size + tItem.m_eAggrFunc = GetAggrFunc ( tBucket, !bRoot ); + switch ( tItem.m_eAggrFunc ) { - if ( !tJsonItem.IsObj() ) - { - sError = R"("aggs" property item should be an object)"; + case Aggr_e::DATE_HISTOGRAM: + if ( !ParseAggrDateHistogram ( tBucket, tItem, sError ) ) return false; - } - - JsonAggr_t tItem; - tItem.m_sBucketName = tJsonItem.Name(); - - JsonObj_c tBucket = tJsonItem.begin(); + tItem.m_iSize = Max ( tItem.m_iSize, 1000 ); // set max_matches to min\max / interval + break; - if ( StrEq ( tBucket.Name(), "aggs" ) || tJsonItem.HasItem ( "aggs" ) ) - { - sError = R"(nested "aggs" is not supported)"; + case Aggr_e::HISTOGRAM: + if ( !ParseAggrHistogram ( tBucket, tItem, sError ) ) return false; - } + tItem.m_iSize = Max ( tItem.m_iSize, 1000 ); // set max_matches to min\max / interval + break; - if ( tBucket==tJsonItem.end() ) - { - sError.SetSprintf ( R"("aggs" bucket '%s' with only nested items)", tItem.m_sBucketName.cstr() ); + case Aggr_e::RANGE: + if ( !ParseAggrRange ( tBucket, tItem, false, sError ) ) return false; - } + tItem.m_iSize = Max ( tItem.m_iSize, tItem.m_tRange.GetLength() + 1 ); // set max_matches to buckets count + _all bucket + break; - if ( !tBucket.IsObj() ) - { - sError.SetSprintf ( R"("aggs" bucket '%s' should be an object)", tItem.m_sBucketName.cstr() ); + case Aggr_e::DATE_RANGE: + if ( !ParseAggrRange ( tBucket, tItem, true, sError ) ) return false; - } - - if ( !StrEq ( tBucket.Name(), "composite" ) && !tBucket.FetchStrItem ( tItem.m_sCol, "field", sError, false ) ) + tItem.m_iSize = Max ( tItem.m_iSize, tItem.m_tDateRange.GetLength() + 1 ); // set max_matches to buckets count + _all bucket + break; + case Aggr_e::COMPOSITE: + if ( !ParseAggrComposite ( tJsonItem, tItem, sError ) ) return false; - - //tBucket.FetchStrItem ( tItem.m_sExpr, "calendar_interval", sError, true ); - tBucket.FetchIntItem ( tItem.m_iSize, "size", sError, true ); - int iShardSize = 0; - tBucket.FetchIntItem ( iShardSize, "shard_size", sError, true ); - tItem.m_iSize = Max ( tItem.m_iSize, iShardSize ); // FIXME!!! use (size * 1.5 + 10) for shard size - tItem.m_eAggrFunc = GetAggrFunc ( tBucket, !bRoot ); - switch ( tItem.m_eAggrFunc ) - { - case Aggr_e::DATE_HISTOGRAM: - if ( !ParseAggrDateHistogram ( tBucket, tItem, sError ) ) - return false; - tItem.m_iSize = Max ( tItem.m_iSize, 1000 ); // set max_matches to min\max / interval break; - - case Aggr_e::HISTOGRAM: - if ( !ParseAggrHistogram ( tBucket, tItem, sError ) ) - return false; - tItem.m_iSize = Max ( tItem.m_iSize, 1000 ); // set max_matches to min\max / interval + case Aggr_e::MIN: + case Aggr_e::MAX: + case Aggr_e::SUM: + case Aggr_e::AVG: + tItem.m_iSize = 1; break; + + default: break; + } - case Aggr_e::RANGE: - if ( !ParseAggrRange ( tBucket, tItem, false, sError ) ) - return false; - tItem.m_iSize = Max ( tItem.m_iSize, tItem.m_tRange.GetLength() + 1 ); // set max_matches to buckets count + _all bucket - break; + return true; +} - case Aggr_e::DATE_RANGE: - if ( !ParseAggrRange ( tBucket, tItem, true, sError ) ) - return false; - tItem.m_iSize = Max ( tItem.m_iSize, tItem.m_tDateRange.GetLength() + 1 ); // set max_matches to buckets count + _all bucket - break; - case Aggr_e::COMPOSITE: - if ( !ParseAggrComposite ( tJsonItem, tItem, sError ) ) - return false; - break; - case Aggr_e::MIN: - case Aggr_e::MAX: - case Aggr_e::SUM: - case Aggr_e::AVG: - tItem.m_iSize = 1; - - default: break; - } +static bool ParseAggsNodeSort ( const JsonObj_c & tJsonItem, bool bOrder, JsonAggr_t & tItem, CSphString & sError ) +{ + if ( !( tJsonItem.IsArray() || tJsonItem.IsObj() ) ) + { + sError.SetSprintf ( "\"%s\" property value should be an array or an object", ( bOrder ? "order" : "sort" ) ); + return false; + } - // could be a sort object at the aggs item or order object at the bucket - bool bOrder = false; - JsonObj_c tSort = tJsonItem.GetItem("sort"); - if ( !tSort && tBucket.HasItem ( "order" ) ) - { - tSort = tBucket.GetItem("order"); - bOrder = true; - } - if ( tSort && !( tSort.IsArray() || tSort.IsObj() ) ) + bool bGotWeight = false; + JsonQuery_c tTmpQuery; + tTmpQuery.m_sSortBy = ""; + tTmpQuery.m_eSort = SPH_SORT_RELEVANCE; + + // FIXME!!! reports warnings for geodist sort + CSphString sWarning; + + if ( !ParseSort ( tJsonItem, tTmpQuery, bGotWeight, sError, sWarning ) ) + return false; + + tItem.m_sSort = tTmpQuery.m_sSortBy; + return true; +} + +static bool AddSubAggregate ( const JsonObj_c & tAggs, bool bRoot, CSphVector & dParentItems, CSphString & sError ) +{ + if ( bRoot && tAggs.begin().Empty() ) + { + JsonAggr_t & tCount = dParentItems.Add(); + tCount.m_eAggrFunc = Aggr_e::COUNT; + tCount.m_iSize = 1; + return true; + } + + for ( const auto & tJsonItem : tAggs ) + { + if ( !tJsonItem.IsObj() ) { - sError.SetSprintf ( "\"%s\" property value should be an array or an object", ( bOrder ? "order" : "sort" ) ); + sError = R"("aggs" property item should be an object)"; return false; } - if ( tSort ) + + JsonAggr_t tItem; + tItem.m_sBucketName = tJsonItem.Name(); + + for ( const auto & tAggsItem : tJsonItem ) { - bool bGotWeight = false; - tTmpQuery.m_sSortBy = ""; - tTmpQuery.m_eSort = SPH_SORT_RELEVANCE; - // FIXME!!! reports warnings for geodist sort - if ( !ParseSort ( tSort, tTmpQuery, bGotWeight, sError, sWarning ) ) - return false; + // could be a sort object at the aggs item or order object at the bucket + if ( strcmp ( tAggsItem.Name(), "sort" )==0 ) + { + if ( !ParseAggsNodeSort ( tAggsItem, false, tItem, sError ) ) + return false; - tItem.m_sSort = tTmpQuery.m_sSortBy; + } else + { + if ( StrEq ( tAggsItem.Name(), "aggs" ) || tAggsItem.HasItem ( "aggs" ) ) + { + sError = R"(nested "aggs" is not supported)"; + return false; + } + if ( tAggsItem==tAggsItem.end() ) + { + sError.SetSprintf ( R"("aggs" bucket '%s' with only nested items)", tAggsItem.Name() ); + return false; + } + if ( !ParseAggsNode ( tAggsItem, tJsonItem, bRoot, tItem, sError ) ) + return false; + + // bucket could have its own order item + if ( tAggsItem.HasItem ( "order" ) ) + { + if ( !ParseAggsNodeSort ( tAggsItem.GetItem("order"), true, tItem, sError ) ) + return false; + } + } } if ( tItem.m_eAggrFunc==Aggr_e::NONE && !bRoot ) { - sError.SetSprintf ( R"(bucket '%s' without aggregate items, item type is '%s')", tItem.m_sBucketName.cstr(), tBucket.Name() ); + sError.SetSprintf ( R"(bucket '%s' without aggregate items)", tItem.m_sBucketName.cstr() ); return false; } diff --git a/test/test_334/model.bin b/test/test_334/model.bin index d11877d37a..5e979edbcf 100644 --- a/test/test_334/model.bin +++ b/test/test_334/model.bin @@ -1,4 +1,4 @@ -a:1:{i:0;a:85:{i:0;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:68:"{ "index": "test1", "query": { "match": { "content": "first" } } } }";s:4:"rows";s:145:"{"timed_out":false,"hits":{"total":1,"total_relation":"eq","hits":[{"_id":1,"_score":1704,"_source":{"title":"1st","content":"first","gid":1}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:1;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:79:"{ "index": "test1", "query": { "match": { "content,title": "1st second" } } } }";s:4:"rows";s:222:"{"timed_out":false,"hits":{"total":2,"total_relation":"eq","hits":[{"_id":1,"_score":1602,"_source":{"title":"1st","content":"first","gid":1}},{"_id":2,"_score":1602,"_source":{"title":"2nd","content":"second","gid":2}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:2;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:80:"{ "index": "test1", "query": { "match": { "content, title": "1st second" } } } }";s:4:"rows";s:113:"{"error":"table test1: query error: error parsing field list: invalid field block operator syntax near ' title'"}";s:9:"http_code";i:500;s:4:"http";i:1;}i:3;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:73:"{ "index": "test1", "query": { "match": { "content": "3rd fourth" } } } }";s:4:"rows";s:146:"{"timed_out":false,"hits":{"total":1,"total_relation":"eq","hits":[{"_id":4,"_score":1602,"_source":{"title":"4th","content":"fourth","gid":4}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:4;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:71:"{ "index": "test1", "query": { "match": { "title": "3rd fourth" } } } }";s:4:"rows";s:145:"{"timed_out":false,"hits":{"total":1,"total_relation":"eq","hits":[{"_id":3,"_score":1602,"_source":{"title":"3rd","content":"third","gid":3}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:5;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:67:"{ "index": "test1", "query": { "match": { "*": "3rd fourth" } } } }";s:4:"rows";s:222:"{"timed_out":false,"hits":{"total":2,"total_relation":"eq","hits":[{"_id":3,"_score":1602,"_source":{"title":"3rd","content":"third","gid":3}},{"_id":4,"_score":1602,"_source":{"title":"4th","content":"fourth","gid":4}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:6;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:70:"{ "index": "test1", "query": { "match": { "_all": "3rd fourth" } } } }";s:4:"rows";s:222:"{"timed_out":false,"hits":{"total":2,"total_relation":"eq","hits":[{"_id":3,"_score":1602,"_source":{"title":"3rd","content":"third","gid":3}},{"_id":4,"_score":1602,"_source":{"title":"4th","content":"fourth","gid":4}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:7;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:52:"{ "index": "test1", "query": { "match_all": {} } } }";s:4:"rows";s:436:"{"timed_out":false,"hits":{"total":5,"total_relation":"eq","hits":[{"_id":1,"_score":1,"_source":{"title":"1st","content":"first","gid":1}},{"_id":2,"_score":1,"_source":{"title":"2nd","content":"second","gid":2}},{"_id":3,"_score":1,"_source":{"title":"3rd","content":"third","gid":3}},{"_id":4,"_score":1,"_source":{"title":"4th","content":"fourth","gid":4}},{"_id":5,"_score":1,"_source":{"title":"5th","content":"fifth","gid":5}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:8;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:69:"{ "index": "*", "query": { "match": { "_all": "first thought" } } } }";s:4:"rows";s:417:"{"timed_out":false,"hits":{"total":3,"total_relation":"eq","hits":[{"_id":1,"_score":1602,"_source":{"title":"1st","content":"first","gid":1}},{"_id":15,"_score":1428,"_source":{"title":"15th","content":"No wonder, Trevize thought, it was indulging itself in this way.","gid":15}},{"_id":16,"_score":1428,"_source":{"title":"","content":"No wonder, Trevize thought, it was indulging itself in this way.","gid":16}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:9;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:72:"{ "index": "_all", "query": { "match": { "_all": "first thought" } } } }";s:4:"rows";s:417:"{"timed_out":false,"hits":{"total":3,"total_relation":"eq","hits":[{"_id":1,"_score":1602,"_source":{"title":"1st","content":"first","gid":1}},{"_id":15,"_score":1428,"_source":{"title":"15th","content":"No wonder, Trevize thought, it was indulging itself in this way.","gid":15}},{"_id":16,"_score":1428,"_source":{"title":"","content":"No wonder, Trevize thought, it was indulging itself in this way.","gid":16}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:10;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:107:"{ "index": "test2", "query": { "match": { "content,title": { "query":"glanced on", "operator":"and" } } } }";s:4:"rows";s:234:"{"timed_out":false,"hits":{"total":1,"total_relation":"eq","hits":[{"_id":10,"_score":1621,"_source":{"title":"10th","content":"Trevize glanced now and then at Bliss`s face, which seemed entirely concentrated on Bander.","gid":10}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:11;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:106:"{ "index": "test2", "query": { "match": { "content,title": { "query":"glanced on", "operator":"or" } } } }";s:4:"rows";s:548:"{"timed_out":false,"hits":{"total":3,"total_relation":"eq","hits":[{"_id":10,"_score":1621,"_source":{"title":"10th","content":"Trevize glanced now and then at Bliss`s face, which seemed entirely concentrated on Bander.","gid":10}},{"_id":11,"_score":1516,"_source":{"title":"11th","content":"Trevize had grown quite certain he knew what was going on.","gid":11}},{"_id":13,"_score":1516,"_source":{"title":"13th","content":"There was no way it could speak to robots on a basis of intellectual equality, and certainly not to animals.","gid":13}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:12;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:88:"{ "index": "test2", "query": { "bool" : { "must" : { "match" : { "_all" : "on" } } } } }";s:4:"rows";s:548:"{"timed_out":false,"hits":{"total":3,"total_relation":"eq","hits":[{"_id":10,"_score":1533,"_source":{"title":"10th","content":"Trevize glanced now and then at Bliss`s face, which seemed entirely concentrated on Bander.","gid":10}},{"_id":11,"_score":1533,"_source":{"title":"11th","content":"Trevize had grown quite certain he knew what was going on.","gid":11}},{"_id":13,"_score":1533,"_source":{"title":"13th","content":"There was no way it could speak to robots on a basis of intellectual equality, and certainly not to animals.","gid":13}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:13;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:88:"{ "index": "test2", "query": { "bool" : { "must" : { "match" : { "_all" : "to" } } } } }";s:4:"rows";s:618:"{"timed_out":false,"hits":{"total":3,"total_relation":"eq","hits":[{"_id":14,"_score":1552,"_source":{"title":"14th","content":"To speak to its fellow-Solarians would be, to it, unpleasant, and what communication there must be would be forced, and never spontaneous.","gid":14}},{"_id":13,"_score":1546,"_source":{"title":"13th","content":"There was no way it could speak to robots on a basis of intellectual equality, and certainly not to animals.","gid":13}},{"_id":12,"_score":1533,"_source":{"title":"12th","content":"Bander, despite its paean to freedom, found this unique opportunity irresistible.","gid":12}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:14;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:124:"{ "index": "test2", "query": { "bool" : { "must": [ { "match" : { "_all" : "to" } }, { "match" : { "_all" : "on" } } ] } } }";s:4:"rows";s:251:"{"timed_out":false,"hits":{"total":1,"total_relation":"eq","hits":[{"_id":13,"_score":1539,"_source":{"title":"13th","content":"There was no way it could speak to robots on a basis of intellectual equality, and certainly not to animals.","gid":13}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:15;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:95:"{ "index": "test2", "query": { "bool" : { "should" : { "match" : { "_all" : "glanced" } } } } }";s:4:"rows";s:234:"{"timed_out":false,"hits":{"total":1,"total_relation":"eq","hits":[{"_id":10,"_score":1709,"_source":{"title":"10th","content":"Trevize glanced now and then at Bliss`s face, which seemed entirely concentrated on Bander.","gid":10}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:16;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:95:"{ "index": "test2", "query": { "bool" : { "should" : { "match" : { "_all" : "despite" } } } } }";s:4:"rows";s:224:"{"timed_out":false,"hits":{"total":1,"total_relation":"eq","hits":[{"_id":12,"_score":1709,"_source":{"title":"12th","content":"Bander, despite its paean to freedom, found this unique opportunity irresistible.","gid":12}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:17;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:137:"{ "index": "test2", "query": { "bool" : { "should": [ { "match" : { "_all" : "glanced " } }, { "match" : { "_all" : "despite" } } ] } } }";s:4:"rows";s:389:"{"timed_out":false,"hits":{"total":2,"total_relation":"eq","hits":[{"_id":10,"_score":1604,"_source":{"title":"10th","content":"Trevize glanced now and then at Bliss`s face, which seemed entirely concentrated on Bander.","gid":10}},{"_id":12,"_score":1604,"_source":{"title":"12th","content":"Bander, despite its paean to freedom, found this unique opportunity irresistible.","gid":12}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:18;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:158:"{ "index": "test2", "query": { "bool": { "must": { "match" : { "_all" : "glanced grown paean" } }, "must_not": { "match" : { "_all" : "irresistible" } } } } }";s:4:"rows";s:366:"{"timed_out":false,"hits":{"total":2,"total_relation":"eq","hits":[{"_id":10,"_score":1552,"_source":{"title":"10th","content":"Trevize glanced now and then at Bliss`s face, which seemed entirely concentrated on Bander.","gid":10}},{"_id":11,"_score":1552,"_source":{"title":"11th","content":"Trevize had grown quite certain he knew what was going on.","gid":11}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:19;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:200:"{ "index": "test2", "query": { "bool": { "must": { "match" : { "_all" : "glanced grown paean" } }, "must_not": [ { "match" : { "_all" : "irresistible" } }, { "match" : { "_all" : "certain" } } ] } } }";s:4:"rows";s:234:"{"timed_out":false,"hits":{"total":1,"total_relation":"eq","hits":[{"_id":10,"_score":1541,"_source":{"title":"10th","content":"Trevize glanced now and then at Bliss`s face, which seemed entirely concentrated on Bander.","gid":10}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:20;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:143:"{ "index": "test2", "query": { "bool": { "must": { "match" : { "_all" : "glanced grown" } }, "should": { "match" : { "_all" : "paean" } } } } }";s:4:"rows";s:366:"{"timed_out":false,"hits":{"total":2,"total_relation":"eq","hits":[{"_id":10,"_score":1569,"_source":{"title":"10th","content":"Trevize glanced now and then at Bliss`s face, which seemed entirely concentrated on Bander.","gid":10}},{"_id":11,"_score":1569,"_source":{"title":"11th","content":"Trevize had grown quite certain he knew what was going on.","gid":11}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:21;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:89:"{ +a:1:{i:0;a:87:{i:0;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:68:"{ "index": "test1", "query": { "match": { "content": "first" } } } }";s:4:"rows";s:145:"{"timed_out":false,"hits":{"total":1,"total_relation":"eq","hits":[{"_id":1,"_score":1704,"_source":{"title":"1st","content":"first","gid":1}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:1;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:79:"{ "index": "test1", "query": { "match": { "content,title": "1st second" } } } }";s:4:"rows";s:222:"{"timed_out":false,"hits":{"total":2,"total_relation":"eq","hits":[{"_id":1,"_score":1602,"_source":{"title":"1st","content":"first","gid":1}},{"_id":2,"_score":1602,"_source":{"title":"2nd","content":"second","gid":2}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:2;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:80:"{ "index": "test1", "query": { "match": { "content, title": "1st second" } } } }";s:4:"rows";s:113:"{"error":"table test1: query error: error parsing field list: invalid field block operator syntax near ' title'"}";s:9:"http_code";i:500;s:4:"http";i:1;}i:3;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:73:"{ "index": "test1", "query": { "match": { "content": "3rd fourth" } } } }";s:4:"rows";s:146:"{"timed_out":false,"hits":{"total":1,"total_relation":"eq","hits":[{"_id":4,"_score":1602,"_source":{"title":"4th","content":"fourth","gid":4}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:4;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:71:"{ "index": "test1", "query": { "match": { "title": "3rd fourth" } } } }";s:4:"rows";s:145:"{"timed_out":false,"hits":{"total":1,"total_relation":"eq","hits":[{"_id":3,"_score":1602,"_source":{"title":"3rd","content":"third","gid":3}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:5;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:67:"{ "index": "test1", "query": { "match": { "*": "3rd fourth" } } } }";s:4:"rows";s:222:"{"timed_out":false,"hits":{"total":2,"total_relation":"eq","hits":[{"_id":3,"_score":1602,"_source":{"title":"3rd","content":"third","gid":3}},{"_id":4,"_score":1602,"_source":{"title":"4th","content":"fourth","gid":4}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:6;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:70:"{ "index": "test1", "query": { "match": { "_all": "3rd fourth" } } } }";s:4:"rows";s:222:"{"timed_out":false,"hits":{"total":2,"total_relation":"eq","hits":[{"_id":3,"_score":1602,"_source":{"title":"3rd","content":"third","gid":3}},{"_id":4,"_score":1602,"_source":{"title":"4th","content":"fourth","gid":4}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:7;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:52:"{ "index": "test1", "query": { "match_all": {} } } }";s:4:"rows";s:436:"{"timed_out":false,"hits":{"total":5,"total_relation":"eq","hits":[{"_id":1,"_score":1,"_source":{"title":"1st","content":"first","gid":1}},{"_id":2,"_score":1,"_source":{"title":"2nd","content":"second","gid":2}},{"_id":3,"_score":1,"_source":{"title":"3rd","content":"third","gid":3}},{"_id":4,"_score":1,"_source":{"title":"4th","content":"fourth","gid":4}},{"_id":5,"_score":1,"_source":{"title":"5th","content":"fifth","gid":5}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:8;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:69:"{ "index": "*", "query": { "match": { "_all": "first thought" } } } }";s:4:"rows";s:417:"{"timed_out":false,"hits":{"total":3,"total_relation":"eq","hits":[{"_id":1,"_score":1602,"_source":{"title":"1st","content":"first","gid":1}},{"_id":15,"_score":1428,"_source":{"title":"15th","content":"No wonder, Trevize thought, it was indulging itself in this way.","gid":15}},{"_id":16,"_score":1428,"_source":{"title":"","content":"No wonder, Trevize thought, it was indulging itself in this way.","gid":16}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:9;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:72:"{ "index": "_all", "query": { "match": { "_all": "first thought" } } } }";s:4:"rows";s:417:"{"timed_out":false,"hits":{"total":3,"total_relation":"eq","hits":[{"_id":1,"_score":1602,"_source":{"title":"1st","content":"first","gid":1}},{"_id":15,"_score":1428,"_source":{"title":"15th","content":"No wonder, Trevize thought, it was indulging itself in this way.","gid":15}},{"_id":16,"_score":1428,"_source":{"title":"","content":"No wonder, Trevize thought, it was indulging itself in this way.","gid":16}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:10;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:107:"{ "index": "test2", "query": { "match": { "content,title": { "query":"glanced on", "operator":"and" } } } }";s:4:"rows";s:234:"{"timed_out":false,"hits":{"total":1,"total_relation":"eq","hits":[{"_id":10,"_score":1621,"_source":{"title":"10th","content":"Trevize glanced now and then at Bliss`s face, which seemed entirely concentrated on Bander.","gid":10}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:11;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:106:"{ "index": "test2", "query": { "match": { "content,title": { "query":"glanced on", "operator":"or" } } } }";s:4:"rows";s:548:"{"timed_out":false,"hits":{"total":3,"total_relation":"eq","hits":[{"_id":10,"_score":1621,"_source":{"title":"10th","content":"Trevize glanced now and then at Bliss`s face, which seemed entirely concentrated on Bander.","gid":10}},{"_id":11,"_score":1516,"_source":{"title":"11th","content":"Trevize had grown quite certain he knew what was going on.","gid":11}},{"_id":13,"_score":1516,"_source":{"title":"13th","content":"There was no way it could speak to robots on a basis of intellectual equality, and certainly not to animals.","gid":13}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:12;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:88:"{ "index": "test2", "query": { "bool" : { "must" : { "match" : { "_all" : "on" } } } } }";s:4:"rows";s:548:"{"timed_out":false,"hits":{"total":3,"total_relation":"eq","hits":[{"_id":10,"_score":1533,"_source":{"title":"10th","content":"Trevize glanced now and then at Bliss`s face, which seemed entirely concentrated on Bander.","gid":10}},{"_id":11,"_score":1533,"_source":{"title":"11th","content":"Trevize had grown quite certain he knew what was going on.","gid":11}},{"_id":13,"_score":1533,"_source":{"title":"13th","content":"There was no way it could speak to robots on a basis of intellectual equality, and certainly not to animals.","gid":13}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:13;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:88:"{ "index": "test2", "query": { "bool" : { "must" : { "match" : { "_all" : "to" } } } } }";s:4:"rows";s:618:"{"timed_out":false,"hits":{"total":3,"total_relation":"eq","hits":[{"_id":14,"_score":1552,"_source":{"title":"14th","content":"To speak to its fellow-Solarians would be, to it, unpleasant, and what communication there must be would be forced, and never spontaneous.","gid":14}},{"_id":13,"_score":1546,"_source":{"title":"13th","content":"There was no way it could speak to robots on a basis of intellectual equality, and certainly not to animals.","gid":13}},{"_id":12,"_score":1533,"_source":{"title":"12th","content":"Bander, despite its paean to freedom, found this unique opportunity irresistible.","gid":12}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:14;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:124:"{ "index": "test2", "query": { "bool" : { "must": [ { "match" : { "_all" : "to" } }, { "match" : { "_all" : "on" } } ] } } }";s:4:"rows";s:251:"{"timed_out":false,"hits":{"total":1,"total_relation":"eq","hits":[{"_id":13,"_score":1539,"_source":{"title":"13th","content":"There was no way it could speak to robots on a basis of intellectual equality, and certainly not to animals.","gid":13}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:15;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:95:"{ "index": "test2", "query": { "bool" : { "should" : { "match" : { "_all" : "glanced" } } } } }";s:4:"rows";s:234:"{"timed_out":false,"hits":{"total":1,"total_relation":"eq","hits":[{"_id":10,"_score":1709,"_source":{"title":"10th","content":"Trevize glanced now and then at Bliss`s face, which seemed entirely concentrated on Bander.","gid":10}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:16;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:95:"{ "index": "test2", "query": { "bool" : { "should" : { "match" : { "_all" : "despite" } } } } }";s:4:"rows";s:224:"{"timed_out":false,"hits":{"total":1,"total_relation":"eq","hits":[{"_id":12,"_score":1709,"_source":{"title":"12th","content":"Bander, despite its paean to freedom, found this unique opportunity irresistible.","gid":12}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:17;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:137:"{ "index": "test2", "query": { "bool" : { "should": [ { "match" : { "_all" : "glanced " } }, { "match" : { "_all" : "despite" } } ] } } }";s:4:"rows";s:389:"{"timed_out":false,"hits":{"total":2,"total_relation":"eq","hits":[{"_id":10,"_score":1604,"_source":{"title":"10th","content":"Trevize glanced now and then at Bliss`s face, which seemed entirely concentrated on Bander.","gid":10}},{"_id":12,"_score":1604,"_source":{"title":"12th","content":"Bander, despite its paean to freedom, found this unique opportunity irresistible.","gid":12}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:18;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:158:"{ "index": "test2", "query": { "bool": { "must": { "match" : { "_all" : "glanced grown paean" } }, "must_not": { "match" : { "_all" : "irresistible" } } } } }";s:4:"rows";s:366:"{"timed_out":false,"hits":{"total":2,"total_relation":"eq","hits":[{"_id":10,"_score":1552,"_source":{"title":"10th","content":"Trevize glanced now and then at Bliss`s face, which seemed entirely concentrated on Bander.","gid":10}},{"_id":11,"_score":1552,"_source":{"title":"11th","content":"Trevize had grown quite certain he knew what was going on.","gid":11}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:19;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:200:"{ "index": "test2", "query": { "bool": { "must": { "match" : { "_all" : "glanced grown paean" } }, "must_not": [ { "match" : { "_all" : "irresistible" } }, { "match" : { "_all" : "certain" } } ] } } }";s:4:"rows";s:234:"{"timed_out":false,"hits":{"total":1,"total_relation":"eq","hits":[{"_id":10,"_score":1541,"_source":{"title":"10th","content":"Trevize glanced now and then at Bliss`s face, which seemed entirely concentrated on Bander.","gid":10}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:20;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:143:"{ "index": "test2", "query": { "bool": { "must": { "match" : { "_all" : "glanced grown" } }, "should": { "match" : { "_all" : "paean" } } } } }";s:4:"rows";s:366:"{"timed_out":false,"hits":{"total":2,"total_relation":"eq","hits":[{"_id":10,"_score":1569,"_source":{"title":"10th","content":"Trevize glanced now and then at Bliss`s face, which seemed entirely concentrated on Bander.","gid":10}},{"_id":11,"_score":1569,"_source":{"title":"11th","content":"Trevize had grown quite certain he knew what was going on.","gid":11}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:21;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:89:"{ "index":"test2", "query": { @@ -208,4 +208,4 @@ a:1:{i:0;a:85:{i:0;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_metho ] } } -}";s:4:"rows";s:234:"{"timed_out":false,"hits":{"total":1,"total_relation":"eq","hits":[{"_id":16,"_score":1356,"_source":{"title":"","content":"No wonder, Trevize thought, it was indulging itself in this way.","gid":16,"title_len":0,"content_len":11}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}}} \ No newline at end of file +}";s:4:"rows";s:234:"{"timed_out":false,"hits":{"total":1,"total_relation":"eq","hits":[{"_id":16,"_score":1356,"_source":{"title":"","content":"No wonder, Trevize thought, it was indulging itself in this way.","gid":16,"title_len":0,"content_len":11}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:85;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:125:"{ "index": "test_gr1", "size":0, "aggs":{ "gr_desc": { "terms": { "field": "gid", "size": 5, "order": {"gid" : "asc"} } } } }";s:4:"rows";s:232:"{"timed_out":false,"hits":{"total":10,"total_relation":"eq","hits":[]},"aggregations":{"gr_desc":{"buckets":[{"key":2,"doc_count":1},{"key":3,"doc_count":2},{"key":4,"doc_count":1},{"key":5,"doc_count":1},{"key":6,"doc_count":1}]}}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:86;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:130:"{ "index": "test_gr1", "size":0, "aggs":{ "gr_desc": { "sort":[{"gid":{"order":"asc"}}], "terms": { "field": "gid", "size": 5 }}}}";s:4:"rows";s:232:"{"timed_out":false,"hits":{"total":10,"total_relation":"eq","hits":[]},"aggregations":{"gr_desc":{"buckets":[{"key":2,"doc_count":1},{"key":3,"doc_count":2},{"key":4,"doc_count":1},{"key":5,"doc_count":1},{"key":6,"doc_count":1}]}}}";s:9:"http_code";i:200;s:4:"http";i:1;}}} \ No newline at end of file diff --git a/test/test_334/test.xml b/test/test_334/test.xml index ca3709d9c6..a2009526f4 100644 --- a/test/test_334/test.xml +++ b/test/test_334/test.xml @@ -653,5 +653,12 @@ select * from dist_gr2 facet gid facet tag;; } + +{ "index": "test_gr1", "size":0, "aggs":{ "gr_desc": { "terms": { "field": "gid", "size": 5, "order": {"gid" : "asc"} } } } } + + +{ "index": "test_gr1", "size":0, "aggs":{ "gr_desc": { "sort":[{"gid":{"order":"asc"}}], "terms": { "field": "gid", "size": 5 }}}} + +