Skip to content

Commit 4ce8752

Browse files
committed
fix(searchByCoordinatesQuery): changed query to be function score based
1 parent fe17305 commit 4ce8752

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

src/location/DAL/queries.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -224,27 +224,31 @@ export const hierarchyQuery = (query: string, disableFuzziness: boolean): estype
224224
export const searchByCoordinatesQuery = ({ lat, lon, limit, source, relation }: GetGeotextSearchByCoordinatesParams): estypes.SearchRequest => {
225225
const esQuery: estypes.SearchRequest = {
226226
query: {
227-
bool: {
228-
filter: [
229-
{
230-
geo_shape: {
231-
[GEOJSON_FIELD]: {
232-
shape: {
233-
type: 'point',
234-
coordinates: [lon, lat],
227+
function_score: {
228+
query: {
229+
bool: {
230+
filter: [
231+
{
232+
geo_shape: {
233+
[GEOJSON_FIELD]: {
234+
shape: {
235+
type: 'point',
236+
coordinates: [lon, lat],
237+
},
238+
relation,
239+
},
235240
},
236-
relation,
237241
},
238-
},
242+
],
239243
},
240-
],
244+
},
241245
},
242246
},
243247
size: limit,
244248
};
245249

246250
source?.length &&
247-
(esQuery.query?.bool?.filter as QueryDslQueryContainer[]).push({
251+
(esQuery.query?.function_score?.query?.bool?.filter as QueryDslQueryContainer[]).push({
248252
terms: {
249253
[SOURCE_FIELD]: source,
250254
},

0 commit comments

Comments
 (0)