diff --git a/backend/src/place/place.service.ts b/backend/src/place/place.service.ts index 66c448f2..8d8777a4 100644 --- a/backend/src/place/place.service.ts +++ b/backend/src/place/place.service.ts @@ -96,8 +96,8 @@ export class PlaceService { name: name, rating: rating || null, location: { - longitude: geometry.location.lng, - latitude: geometry.location.lat, + longitude: geometry.location.longitude, + latitude: geometry.location.latitude, }, formattedAddress: formatted_address || null, category: types?.[0] || null, diff --git a/backend/src/search/dto/ESPlaceSaveDTO.ts b/backend/src/search/dto/ESPlaceSaveDTO.ts index c30c9b22..1c3f8131 100644 --- a/backend/src/search/dto/ESPlaceSaveDTO.ts +++ b/backend/src/search/dto/ESPlaceSaveDTO.ts @@ -8,8 +8,8 @@ export class ESPlaceSaveDTO { readonly thumbnailUrl: string, readonly rating: number, readonly location: { - lat: number; - lon: number; + latitude: number; + longitude: number; }, readonly formattedAddress: string, readonly category: string, @@ -28,8 +28,8 @@ export class ESPlaceSaveDTO { place.thumbnailUrl, place.rating, { - lat: place.latitude, - lon: place.longitude, + latitude: place.latitude, + longitude: place.longitude, }, place.formattedAddress, place.category, diff --git a/backend/src/search/query/ElasticSearchQuery.ts b/backend/src/search/query/ElasticSearchQuery.ts index 94191c20..d133c5bb 100644 --- a/backend/src/search/query/ElasticSearchQuery.ts +++ b/backend/src/search/query/ElasticSearchQuery.ts @@ -9,13 +9,19 @@ export class ElasticSearchQuery { async searchPlace( query: string, - lat?: number, - long?: number, + latitude?: number, + longitude?: number, page: number = 1, size: number = 10, ) { const tokens = await this.tokenizeQuery(query); - const location = !isNaN(lat) && !isNaN(long) ? { lat, long: long } : null; + const location = + !isNaN(latitude) && !isNaN(longitude) + ? { + latitude: latitude, + longitude: longitude, + } + : null; const from = (page - 1) * size; return await this.esService.search({ index: ElasticSearchConfig.PLACE_INDEX, @@ -56,8 +62,8 @@ export class ElasticSearchQuery { ...(location ? [ ElasticSearchQueryBuilder.GAUSS_LOCATION( - location.lat, - location.long, + location.latitude, + location.longitude, ), ] : []), diff --git a/backend/src/search/query/builder/LocationBuilder.ts b/backend/src/search/query/builder/LocationBuilder.ts index cdb77ef3..00a2340a 100644 --- a/backend/src/search/query/builder/LocationBuilder.ts +++ b/backend/src/search/query/builder/LocationBuilder.ts @@ -1,7 +1,7 @@ export const LocationQueryBuilders = { GAUSS_LOCATION: ( - lat: number, - long: number, + latitude: number, + longitude: number, scale = '10km', offset = '2km', decay = 0.5, @@ -9,7 +9,7 @@ export const LocationQueryBuilders = { ) => ({ gauss: { location: { - origin: `${lat},${long}`, + origin: `${latitude},${longitude}`, scale: scale, offset: offset, decay: decay, diff --git a/backend/src/search/search.controller.ts b/backend/src/search/search.controller.ts index f586842e..bfbd5afe 100644 --- a/backend/src/search/search.controller.ts +++ b/backend/src/search/search.controller.ts @@ -9,11 +9,17 @@ export class SearchController { @Get() async search( @Query('query') query: string, - @Query('lat') lat?: number, - @Query('long') long?: number, + @Query('latitude') latitude?: number, + @Query('longitude') longitude?: number, @Query('page', new ParseOptionalNumberPipe(1)) page?: number, @Query('limit', new ParseOptionalNumberPipe(10)) limit?: number, ) { - return await this.searchService.searchPlace(query, lat, long, page, limit); + return await this.searchService.searchPlace( + query, + latitude, + longitude, + page, + limit, + ); } } diff --git a/backend/src/search/search.service.ts b/backend/src/search/search.service.ts index 67cb5bf9..47f0e1fa 100644 --- a/backend/src/search/search.service.ts +++ b/backend/src/search/search.service.ts @@ -35,15 +35,15 @@ export class SearchService { async searchPlace( query: string, - lat?: number, - long?: number, + latitude?: number, + longitude?: number, page: number = 1, size: number = 10, ) { const searched = await this.elasticSearchQuery.searchPlace( query, - lat, - long, + latitude, + longitude, page, size, ); @@ -61,8 +61,8 @@ export class SearchService { _source.name, _source.location ? { - latitude: _source.location.lat, - longitude: _source.location.long, + latitude: _source.location.latitude, + longitude: _source.location.longitude, } : null, _source.googlePlaceId, diff --git a/backend/src/search/search.type.ts b/backend/src/search/search.type.ts index a4be0802..c14b1281 100644 --- a/backend/src/search/search.type.ts +++ b/backend/src/search/search.type.ts @@ -6,8 +6,8 @@ export type PlaceSearchHit = { id: string; name: string; location: { - lat: number; - long: number; + latitude: number; + longitude: number; }; googlePlaceId: string; category: string | null;