UNPKG

graphql-compose-elasticsearch

Version:
39 lines 1.61 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getGeoDistanceITC = void 0; const utils_1 = require("../../../utils"); const FieldNames_1 = require("../../Commons/FieldNames"); const Geo_1 = require("../../Commons/Geo"); function getGeoDistanceITC(opts) { const name = (0, utils_1.getTypeName)('QueryGeoDistance', opts); const description = (0, utils_1.desc)(` Filters documents that include only hits that exists within a specific distance from a geo point. Requires the geo_point Mapping. [Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-query.html) `); const subName = (0, utils_1.getTypeName)('QueryGeoDistanceSettings', opts); const fields = (0, FieldNames_1.getGeoPointAsFieldConfigMap)(opts, opts.getOrCreateITC(subName, () => ({ name: subName, fields: { top_left: (0, Geo_1.getGeoPointFC)(opts), bottom_right: (0, Geo_1.getGeoPointFC)(opts), }, }))); if (typeof fields === 'object') { return opts.getOrCreateITC(name, () => ({ name, description, fields: Object.assign(Object.assign({ distance: { type: 'String!', description: 'Eg. 12km', }, distance_type: (0, Geo_1.getDistanceCalculationModeFC)(opts) }, fields), { validation_method: 'String' }), })); } return { type: 'JSON', description, }; } exports.getGeoDistanceITC = getGeoDistanceITC; //# sourceMappingURL=GeoDistance.js.map