mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-22 01:22:54 +00:00
refactor: use core supplied mappings
This commit is contained in:
committed by
Rainer Killinger
parent
614a1b1e9b
commit
43a89ec4f2
@@ -16,118 +16,9 @@
|
||||
import {SCFacet, SCThingType} from '@openstapps/core';
|
||||
import {expect} from 'chai';
|
||||
import {parseAggregations} from '../../../src/storage/elasticsearch/aggregations';
|
||||
import {AggregationResponse, AggregationSchema} from '../../../src/storage/elasticsearch/common';
|
||||
import {AggregationResponse} from '../../../src/storage/elasticsearch/types/elasticsearch';
|
||||
|
||||
describe('Aggregations', function () {
|
||||
const schema: AggregationSchema = {
|
||||
'@all': {
|
||||
aggs: {
|
||||
type: {
|
||||
terms: {
|
||||
field: 'type.raw',
|
||||
size: 1000
|
||||
}
|
||||
}
|
||||
},
|
||||
filter: {
|
||||
match_all: {}
|
||||
}
|
||||
},
|
||||
'academic event': {
|
||||
aggs: {
|
||||
'academicTerms.acronym': {
|
||||
terms: {
|
||||
field: 'academicTerms.acronym.raw',
|
||||
size: 1000
|
||||
}
|
||||
},
|
||||
'catalogs.categories': {
|
||||
terms: {
|
||||
field: 'catalogs.categories.raw',
|
||||
size: 1000
|
||||
}
|
||||
},
|
||||
categories: {
|
||||
terms: {
|
||||
field: 'categories.raw',
|
||||
size: 1000
|
||||
}
|
||||
},
|
||||
'creativeWorks.keywords': {
|
||||
terms: {
|
||||
field: 'creativeWorks.keywords.raw',
|
||||
size: 1000
|
||||
}
|
||||
},
|
||||
majors: {
|
||||
terms: {
|
||||
field: 'majors.raw',
|
||||
size: 1000
|
||||
}
|
||||
}
|
||||
},
|
||||
filter: {
|
||||
type: {
|
||||
value: 'academic event'
|
||||
}
|
||||
}
|
||||
},
|
||||
catalog: {
|
||||
aggs: {
|
||||
'academicTerm.acronym': {
|
||||
terms: {
|
||||
field: 'academicTerm.acronym.raw',
|
||||
size: 1000
|
||||
}
|
||||
},
|
||||
categories: {
|
||||
terms: {
|
||||
field: 'categories.raw',
|
||||
size: 1000
|
||||
}
|
||||
},
|
||||
'superCatalog.categories': {
|
||||
terms: {
|
||||
field: 'superCatalog.categories.raw',
|
||||
size: 1000
|
||||
}
|
||||
},
|
||||
'superCatalogs.categories': {
|
||||
terms: {
|
||||
field: 'superCatalogs.categories.raw',
|
||||
size: 1000
|
||||
}
|
||||
}
|
||||
},
|
||||
filter: {
|
||||
type: {
|
||||
value: 'catalog'
|
||||
}
|
||||
}
|
||||
},
|
||||
person: {
|
||||
aggs: {
|
||||
'homeLocations.categories': {
|
||||
terms: {
|
||||
field: 'homeLocations.categories.raw',
|
||||
size: 1000
|
||||
}
|
||||
}
|
||||
},
|
||||
filter: {
|
||||
type: {
|
||||
value: 'person'
|
||||
}
|
||||
}
|
||||
},
|
||||
fooType: {
|
||||
terms: {
|
||||
field: 'foo',
|
||||
size: 123,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const aggregations: AggregationResponse = {
|
||||
catalog: {
|
||||
doc_count: 4,
|
||||
@@ -262,19 +153,11 @@ describe('Aggregations', function () {
|
||||
field: 'categories',
|
||||
onlyOnType: SCThingType.Catalog,
|
||||
},
|
||||
{
|
||||
buckets: [
|
||||
{
|
||||
count: 321,
|
||||
key: 'foo'
|
||||
}
|
||||
],
|
||||
field: 'fooType'
|
||||
}
|
||||
// no fooType as it doesn't appear in the aggregation schema
|
||||
];
|
||||
|
||||
it('should parse the aggregations providing the appropriate facets', function () {
|
||||
const facets = parseAggregations(schema, aggregations);
|
||||
const facets = parseAggregations(aggregations);
|
||||
|
||||
expect(facets).to.be.eql(expectedFacets);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user