Skip to content

Commit 071d81e

Browse files
committed
Implemented composite aggregation
1 parent d7c01f3 commit 071d81e

13 files changed

+334
-31
lines changed

docs/Aggregation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
77
**terms** | [**AggregationTerms**](AggregationTerms.md) | | [optional]
88
**sort** | **[{String: AggregationSortInnerValue}]** | | [optional]
9+
**composite** | [**AggregationComposite**](AggregationComposite.md) | | [optional]
910

1011
[[Using in search requests]](SearchRequest.md#Aggregation)
1112

docs/AggregationComposite.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Manticoresearch.AggregationComposite
2+
3+
## Properties
4+
5+
Name | Type | Description | Notes
6+
------------ | ------------- | ------------- | -------------
7+
**size** | **Number** | Maximum number of composite buckets in the result | [optional]
8+
**sources** | **[{String: AggregationCompositeSourcesInnerValue}]** | | [optional]
9+
10+
11+
12+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Manticoresearch.AggregationCompositeSourcesInnerValue
2+
3+
## Properties
4+
5+
Name | Type | Description | Notes
6+
------------ | ------------- | ------------- | -------------
7+
**terms** | [**AggregationCompositeSourcesInnerValueTerms**](AggregationCompositeSourcesInnerValueTerms.md) | | [optional]
8+
9+
10+
11+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Manticoresearch.AggregationCompositeSourcesInnerValueTerms
2+
3+
## Properties
4+
5+
Name | Type | Description | Notes
6+
------------ | ------------- | ------------- | -------------
7+
**field** | **String** | Name of attribute to aggregate by | [optional]
8+
9+
10+
11+

docs/AggregationTerms.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
7-
**field** | **String** | Attribute Name to Aggregate | [optional]
8-
**size** | **Number** | Maximum Number of Buckets in the Result | [optional]
7+
**field** | **String** | Name of attribute to aggregate by | [optional]
8+
**size** | **Number** | Maximum number of buckets in the result | [optional]
99

1010

1111

docs/SearchRequest.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,21 @@ var agg2 = new Manticoresearch.Aggregation();
147147
agg2['terms'] = Manticoresearch.AggregationTerms.constructFromObject({field: 'rating'});
148148
searchRequest.aggs['agg2'] = agg2;
149149

150+
async function(){
151+
var res = await searchApi.search(searchRequest);
152+
console.log(JSON.stringify(res, null, 4));
153+
}
154+
155+
// Composite aggregation example
156+
var compAggTerms1 = Manticoresearch.AggregationCompositeSourcesInnerValueTerms.constructFromObject({field: '_year'});
157+
var compAgg1 = Manticoresearch.AggregationCompositeSourcesInnerValue.constructFromObject({'terms': compAggTerms1})
158+
var compAggTerms2 = Manticoresearch.AggregationCompositeSourcesInnerValueTerms.constructFromObject({field: 'rating'});
159+
var compAgg2 = Manticoresearch.AggregationCompositeSourcesInnerValue.constructFromObject({'terms': compAggTerms2});
160+
var compSources = [{'comp_agg_1': compAgg1}, {'comp_agg_2': compAgg2}];
161+
var compAgg = Manticoresearch.AggregationComposite.constructFromObject({'size': 5, 'sources': compSources});
162+
var agg = Manticoresearch.Aggregation.constructFromObject({'composite': compAgg});
163+
searchRequest.aggs = {'comp_agg': agg};
164+
150165
async function(){
151166
var res = await searchApi.search(searchRequest);
152167
console.log(JSON.stringify(res, null, 4));

src/index.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
(function(factory) {
99
if (typeof define === 'function' && define.amd) {
1010
// AMD. Register as an anonymous module.
11-
define(['ApiClient', 'model/Aggregation', 'model/AggregationSortInnerValue', 'model/AggregationTerms', 'model/BoolFilter', 'model/BulkResponse', 'model/DeleteDocumentRequest', 'model/DeleteResponse', 'model/EqualsFilter', 'model/ErrorResponse', 'model/Facet', 'model/FilterBoolean', 'model/FilterNumber', 'model/FilterString', 'model/GeoDistanceFilter', 'model/GeoDistanceFilterLocationAnchor', 'model/Highlight', 'model/HighlightField', 'model/InFilter', 'model/InsertDocumentRequest', 'model/KnnQueryByDocId', 'model/KnnQueryByVector', 'model/MatchFilter', 'model/MatchOp', 'model/MatchOpFilter', 'model/MatchPhraseFilter', 'model/NotFilterBoolean', 'model/NotFilterNumber', 'model/NotFilterString', 'model/PercolateRequest', 'model/PercolateRequestQuery', 'model/QueryFilter', 'model/RangeFilter', 'model/ReplaceDocumentRequest', 'model/SearchRequest', 'model/SearchRequestKnn', 'model/SearchResponse', 'model/SearchResponseHits', 'model/SortMVA', 'model/SortMultiple', 'model/SortOrder', 'model/SourceByRules', 'model/SuccessResponse', 'model/UpdateDocumentRequest', 'model/UpdateResponse', 'api/IndexApi', 'api/SearchApi', 'api/UtilsApi'], factory);
11+
define(['ApiClient', 'model/Aggregation', 'model/AggregationComposite', 'model/AggregationCompositeSourcesInnerValue', 'model/AggregationCompositeSourcesInnerValueTerms', 'model/AggregationSortInnerValue', 'model/AggregationTerms', 'model/BoolFilter', 'model/BulkResponse', 'model/DeleteDocumentRequest', 'model/DeleteResponse', 'model/EqualsFilter', 'model/ErrorResponse', 'model/Facet', 'model/FilterBoolean', 'model/FilterNumber', 'model/FilterString', 'model/GeoDistanceFilter', 'model/GeoDistanceFilterLocationAnchor', 'model/Highlight', 'model/HighlightField', 'model/InFilter', 'model/InsertDocumentRequest', 'model/MatchFilter', 'model/MatchOp', 'model/MatchOpFilter', 'model/MatchPhraseFilter', 'model/NotFilterBoolean', 'model/NotFilterNumber', 'model/NotFilterString', 'model/PercolateRequest', 'model/PercolateRequestQuery', 'model/QueryFilter', 'model/RangeFilter', 'model/ReplaceDocumentRequest', 'model/SearchRequest', 'model/SearchResponse', 'model/SearchResponseHits', 'model/SortMVA', 'model/SortMultiple', 'model/SortOrder', 'model/SourceByRules', 'model/SuccessResponse', 'model/UpdateDocumentRequest', 'model/UpdateResponse', 'api/IndexApi', 'api/SearchApi', 'api/UtilsApi'], factory);
1212
} else if (typeof module === 'object' && module.exports) {
1313
// CommonJS-like environments that support module.exports, like Node.
14-
module.exports = factory(require('./ApiClient'), require('./model/Aggregation'), require('./model/AggregationSortInnerValue'), require('./model/AggregationTerms'), require('./model/BoolFilter'), require('./model/BulkResponse'), require('./model/DeleteDocumentRequest'), require('./model/DeleteResponse'), require('./model/EqualsFilter'), require('./model/ErrorResponse'), require('./model/Facet'), require('./model/FilterBoolean'), require('./model/FilterNumber'), require('./model/FilterString'), require('./model/GeoDistanceFilter'), require('./model/GeoDistanceFilterLocationAnchor'), require('./model/Highlight'), require('./model/HighlightField'), require('./model/InFilter'), require('./model/InsertDocumentRequest'), require('./model/KnnQueryByDocId'), require('./model/KnnQueryByVector'), require('./model/MatchFilter'), require('./model/MatchOp'), require('./model/MatchOpFilter'), require('./model/MatchPhraseFilter'), require('./model/NotFilterBoolean'), require('./model/NotFilterNumber'), require('./model/NotFilterString'), require('./model/PercolateRequest'), require('./model/PercolateRequestQuery'), require('./model/QueryFilter'), require('./model/RangeFilter'), require('./model/ReplaceDocumentRequest'), require('./model/SearchRequest'), require('./model/SearchRequestKnn'), require('./model/SearchResponse'), require('./model/SearchResponseHits'), require('./model/SortMVA'), require('./model/SortMultiple'), require('./model/SortOrder'), require('./model/SourceByRules'), require('./model/SuccessResponse'), require('./model/UpdateDocumentRequest'), require('./model/UpdateResponse'), require('./api/IndexApi'), require('./api/SearchApi'), require('./api/UtilsApi'));
14+
module.exports = factory(require('./ApiClient'), require('./model/Aggregation'), require('./model/AggregationComposite'), require('./model/AggregationCompositeSourcesInnerValue'), require('./model/AggregationCompositeSourcesInnerValueTerms'), require('./model/AggregationSortInnerValue'), require('./model/AggregationTerms'), require('./model/BoolFilter'), require('./model/BulkResponse'), require('./model/DeleteDocumentRequest'), require('./model/DeleteResponse'), require('./model/EqualsFilter'), require('./model/ErrorResponse'), require('./model/Facet'), require('./model/FilterBoolean'), require('./model/FilterNumber'), require('./model/FilterString'), require('./model/GeoDistanceFilter'), require('./model/GeoDistanceFilterLocationAnchor'), require('./model/Highlight'), require('./model/HighlightField'), require('./model/InFilter'), require('./model/InsertDocumentRequest'), require('./model/MatchFilter'), require('./model/MatchOp'), require('./model/MatchOpFilter'), require('./model/MatchPhraseFilter'), require('./model/NotFilterBoolean'), require('./model/NotFilterNumber'), require('./model/NotFilterString'), require('./model/PercolateRequest'), require('./model/PercolateRequestQuery'), require('./model/QueryFilter'), require('./model/RangeFilter'), require('./model/ReplaceDocumentRequest'), require('./model/SearchRequest'), require('./model/SearchResponse'), require('./model/SearchResponseHits'), require('./model/SortMVA'), require('./model/SortMultiple'), require('./model/SortOrder'), require('./model/SourceByRules'), require('./model/SuccessResponse'), require('./model/UpdateDocumentRequest'), require('./model/UpdateResponse'), require('./api/IndexApi'), require('./api/SearchApi'), require('./api/UtilsApi'));
1515
}
16-
}(function(ApiClient, Aggregation, AggregationSortInnerValue, AggregationTerms, BoolFilter, BulkResponse, DeleteDocumentRequest, DeleteResponse, EqualsFilter, ErrorResponse, Facet, FilterBoolean, FilterNumber, FilterString, GeoDistanceFilter, GeoDistanceFilterLocationAnchor, Highlight, HighlightField, InFilter, InsertDocumentRequest, KnnQueryByDocId, KnnQueryByVector, MatchFilter, MatchOp, MatchOpFilter, MatchPhraseFilter, NotFilterBoolean, NotFilterNumber, NotFilterString, PercolateRequest, PercolateRequestQuery, QueryFilter, RangeFilter, ReplaceDocumentRequest, SearchRequest, SearchRequestKnn, SearchResponse, SearchResponseHits, SortMVA, SortMultiple, SortOrder, SourceByRules, SuccessResponse, UpdateDocumentRequest, UpdateResponse, IndexApi, SearchApi, UtilsApi) {
16+
}(function(ApiClient, Aggregation, AggregationComposite, AggregationCompositeSourcesInnerValue, AggregationCompositeSourcesInnerValueTerms, AggregationSortInnerValue, AggregationTerms, BoolFilter, BulkResponse, DeleteDocumentRequest, DeleteResponse, EqualsFilter, ErrorResponse, Facet, FilterBoolean, FilterNumber, FilterString, GeoDistanceFilter, GeoDistanceFilterLocationAnchor, Highlight, HighlightField, InFilter, InsertDocumentRequest, MatchFilter, MatchOp, MatchOpFilter, MatchPhraseFilter, NotFilterBoolean, NotFilterNumber, NotFilterString, PercolateRequest, PercolateRequestQuery, QueryFilter, RangeFilter, ReplaceDocumentRequest, SearchRequest, SearchResponse, SearchResponseHits, SortMVA, SortMultiple, SortOrder, SourceByRules, SuccessResponse, UpdateDocumentRequest, UpdateResponse, IndexApi, SearchApi, UtilsApi) {
1717
'use strict';
1818

1919
/**
@@ -58,6 +58,21 @@
5858
* @property {module:model/Aggregation}
5959
*/
6060
Aggregation: Aggregation,
61+
/**
62+
* The AggregationComposite model constructor.
63+
* @property {module:model/AggregationComposite}
64+
*/
65+
AggregationComposite: AggregationComposite,
66+
/**
67+
* The AggregationCompositeSourcesInnerValue model constructor.
68+
* @property {module:model/AggregationCompositeSourcesInnerValue}
69+
*/
70+
AggregationCompositeSourcesInnerValue: AggregationCompositeSourcesInnerValue,
71+
/**
72+
* The AggregationCompositeSourcesInnerValueTerms model constructor.
73+
* @property {module:model/AggregationCompositeSourcesInnerValueTerms}
74+
*/
75+
AggregationCompositeSourcesInnerValueTerms: AggregationCompositeSourcesInnerValueTerms,
6176
/**
6277
* The AggregationSortInnerValue model constructor.
6378
* @property {module:model/AggregationSortInnerValue}

src/model/Aggregation.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88
(function(root, factory) {
99
if (typeof define === 'function' && define.amd) {
1010
// AMD. Register as an anonymous module.
11-
define(['ApiClient', 'model/AggregationSortInnerValue', 'model/AggregationTerms'], factory);
11+
define(['ApiClient', 'model/AggregationComposite', 'model/AggregationSortInnerValue', 'model/AggregationTerms'], factory);
1212
} else if (typeof module === 'object' && module.exports) {
1313
// CommonJS-like environments that support module.exports, like Node.
14-
module.exports = factory(require('../ApiClient'), require('./AggregationSortInnerValue'), require('./AggregationTerms'));
14+
module.exports = factory(require('../ApiClient'), require('./AggregationComposite'), require('./AggregationSortInnerValue'), require('./AggregationTerms'));
1515
} else {
1616
// Browser globals (root is window)
1717
if (!root.Manticoresearch) {
1818
root.Manticoresearch = {};
1919
}
20-
root.Manticoresearch.Aggregation = factory(root.Manticoresearch.ApiClient, root.Manticoresearch.AggregationSortInnerValue, root.Manticoresearch.AggregationTerms);
20+
root.Manticoresearch.Aggregation = factory(root.Manticoresearch.ApiClient, root.Manticoresearch.AggregationComposite, root.Manticoresearch.AggregationSortInnerValue, root.Manticoresearch.AggregationTerms);
2121
}
22-
}(this, function(ApiClient, AggregationSortInnerValue, AggregationTerms) {
22+
}(this, function(ApiClient, AggregationComposite, AggregationSortInnerValue, AggregationTerms) {
2323
'use strict';
2424

2525

@@ -57,6 +57,9 @@
5757
if (data.hasOwnProperty('sort')) {
5858
obj['sort'] = ApiClient.convertToType(data['sort'], [{'String': AggregationSortInnerValue}]);
5959
}
60+
if (data.hasOwnProperty('composite')) {
61+
obj['composite'] = AggregationComposite.constructFromObject(data['composite']);
62+
}
6063
}
6164
return obj;
6265
}
@@ -69,6 +72,10 @@
6972
* @member {Array.<Object.<String, module:model/AggregationSortInnerValue>>} sort
7073
*/
7174
exports.prototype['sort'] = undefined;
75+
/**
76+
* @member {module:model/AggregationComposite} composite
77+
*/
78+
exports.prototype['composite'] = undefined;
7279

7380

7481

src/model/AggregationComposite.js

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* Manticore Search Client
3+
* Copyright (c) 2020-2021, Manticore Software LTD (https://manticoresearch.com)
4+
*
5+
* All rights reserved
6+
*/
7+
8+
(function(root, factory) {
9+
if (typeof define === 'function' && define.amd) {
10+
// AMD. Register as an anonymous module.
11+
define(['ApiClient', 'model/AggregationCompositeSourcesInnerValue'], factory);
12+
} else if (typeof module === 'object' && module.exports) {
13+
// CommonJS-like environments that support module.exports, like Node.
14+
module.exports = factory(require('../ApiClient'), require('./AggregationCompositeSourcesInnerValue'));
15+
} else {
16+
// Browser globals (root is window)
17+
if (!root.Manticoresearch) {
18+
root.Manticoresearch = {};
19+
}
20+
root.Manticoresearch.AggregationComposite = factory(root.Manticoresearch.ApiClient, root.Manticoresearch.AggregationCompositeSourcesInnerValue);
21+
}
22+
}(this, function(ApiClient, AggregationCompositeSourcesInnerValue) {
23+
'use strict';
24+
25+
26+
27+
/**
28+
* The AggregationComposite model module.
29+
* @module model/AggregationComposite
30+
* @version 4.0.0
31+
*/
32+
33+
/**
34+
* Constructs a new <code>AggregationComposite</code>.
35+
* Composite aggregation
36+
* @alias module:model/AggregationComposite
37+
* @class
38+
*/
39+
var exports = function() {
40+
var _this = this;
41+
42+
};
43+
44+
/**
45+
* Constructs a <code>AggregationComposite</code> from a plain JavaScript object, optionally creating a new instance.
46+
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
47+
* @param {Object} data The plain JavaScript object bearing properties of interest.
48+
* @param {module:model/AggregationComposite} obj Optional instance to populate.
49+
* @return {module:model/AggregationComposite} The populated <code>AggregationComposite</code> instance.
50+
*/
51+
exports.constructFromObject = function(data, obj) {
52+
if (data) {
53+
obj = obj || new exports();
54+
if (data.hasOwnProperty('size')) {
55+
obj['size'] = ApiClient.convertToType(data['size'], 'Number');
56+
}
57+
if (data.hasOwnProperty('sources')) {
58+
obj['sources'] = ApiClient.convertToType(data['sources'], [{'String': AggregationCompositeSourcesInnerValue}]);
59+
}
60+
}
61+
return obj;
62+
}
63+
64+
/**
65+
* Maximum number of composite buckets in the result
66+
* @member {Number} size
67+
*/
68+
exports.prototype['size'] = undefined;
69+
/**
70+
* @member {Array.<Object.<String, module:model/AggregationCompositeSourcesInnerValue>>} sources
71+
*/
72+
exports.prototype['sources'] = undefined;
73+
74+
75+
76+
return exports;
77+
}));
78+
79+
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Manticore Search Client
3+
* Copyright (c) 2020-2021, Manticore Software LTD (https://manticoresearch.com)
4+
*
5+
* All rights reserved
6+
*/
7+
8+
(function(root, factory) {
9+
if (typeof define === 'function' && define.amd) {
10+
// AMD. Register as an anonymous module.
11+
define(['ApiClient', 'model/AggregationCompositeSourcesInnerValueTerms'], factory);
12+
} else if (typeof module === 'object' && module.exports) {
13+
// CommonJS-like environments that support module.exports, like Node.
14+
module.exports = factory(require('../ApiClient'), require('./AggregationCompositeSourcesInnerValueTerms'));
15+
} else {
16+
// Browser globals (root is window)
17+
if (!root.Manticoresearch) {
18+
root.Manticoresearch = {};
19+
}
20+
root.Manticoresearch.AggregationCompositeSourcesInnerValue = factory(root.Manticoresearch.ApiClient, root.Manticoresearch.AggregationCompositeSourcesInnerValueTerms);
21+
}
22+
}(this, function(ApiClient, AggregationCompositeSourcesInnerValueTerms) {
23+
'use strict';
24+
25+
26+
27+
/**
28+
* The AggregationCompositeSourcesInnerValue model module.
29+
* @module model/AggregationCompositeSourcesInnerValue
30+
* @version 4.0.0
31+
*/
32+
33+
/**
34+
* Constructs a new <code>AggregationCompositeSourcesInnerValue</code>.
35+
* @alias module:model/AggregationCompositeSourcesInnerValue
36+
* @class
37+
*/
38+
var exports = function() {
39+
var _this = this;
40+
41+
};
42+
43+
/**
44+
* Constructs a <code>AggregationCompositeSourcesInnerValue</code> from a plain JavaScript object, optionally creating a new instance.
45+
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
46+
* @param {Object} data The plain JavaScript object bearing properties of interest.
47+
* @param {module:model/AggregationCompositeSourcesInnerValue} obj Optional instance to populate.
48+
* @return {module:model/AggregationCompositeSourcesInnerValue} The populated <code>AggregationCompositeSourcesInnerValue</code> instance.
49+
*/
50+
exports.constructFromObject = function(data, obj) {
51+
if (data) {
52+
obj = obj || new exports();
53+
if (data.hasOwnProperty('terms')) {
54+
obj['terms'] = AggregationCompositeSourcesInnerValueTerms.constructFromObject(data['terms']);
55+
}
56+
}
57+
return obj;
58+
}
59+
60+
/**
61+
* @member {module:model/AggregationCompositeSourcesInnerValueTerms} terms
62+
*/
63+
exports.prototype['terms'] = undefined;
64+
65+
66+
67+
return exports;
68+
}));
69+
70+

0 commit comments

Comments
 (0)