Skip to content

Commit

Permalink
Merge pull request #2853 from jpetar/feature/suggest
Browse files Browse the repository at this point in the history
Feature - Elastic Search Suggestions
  • Loading branch information
patzick authored May 5, 2019
2 parents e339416 + e7515eb commit 4fcbcb1
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Portuguese (pt-PT) translation - @xlcnd (#2695)
- Added `syncTasks` cleanup, `elasticCacheQuota` lowered to 3096KB - @pkarw (#2729)
- Added back-button on orde detail page [#2819]
- Added Elastic Search Suggestions in the Search Response - @jpetar (#2853)

### Fixed
- Sidebar menu wasn't possible to scroll - @PanMisza (#2627)
Expand Down
3 changes: 2 additions & 1 deletion core/lib/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ export const quickSearchByQuery = async ({ query, start = 0, size = 50, entityT
aggregations: {},
offline: true,
cache: true,
noresults: true
noresults: true,
suggestions: {}
}
resolve(res)
}
Expand Down
4 changes: 4 additions & 0 deletions core/lib/search/adapter/api/elasticsearchQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,9 @@ export async function prepareElasticsearchQueryBody (searchQuery) {
}
const queryBody = query.build()

if (searchQuery.suggest) {
queryBody.suggest = searchQuery.suggest
}

return queryBody
}
3 changes: 2 additions & 1 deletion core/lib/search/adapter/api/searchAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ export class SearchAdapter {
total: resp.hits.total,
start: start,
perPage: size,
aggregations: resp.aggregations
aggregations: resp.aggregations,
suggestions: resp.suggest
}
} else {
if (resp.error) {
Expand Down
9 changes: 6 additions & 3 deletions core/lib/search/adapter/graphql/processor/processType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export function processESResponseType (resp, start, size): SearchResponse {
total: resp.hits.total,
start: start,
perPage: size,
aggregations: resp.aggregations
aggregations: resp.aggregations,
suggestions: resp.suggest
}

return response
Expand All @@ -40,7 +41,8 @@ export function processProductsType (resp, start, size): SearchResponse {
total: resp.total_count,
start: start,
perPage: size,
aggregations: resp.aggregations
aggregations: resp.aggregations,
suggestions: resp.suggest
}

return response
Expand All @@ -52,7 +54,8 @@ export function processCmsType (resp, start, size): SearchResponse {
total: resp.total_count,
start: start,
perPage: size,
aggregations: resp.aggregations
aggregations: resp.aggregations,
suggestions: resp.suggest
}

return response
Expand Down
1 change: 1 addition & 0 deletions core/types/search/SearchResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface SearchResponse {
offline?: boolean
cache?: boolean
noresults?: boolean
suggestions: any
}

export {
Expand Down

0 comments on commit 4fcbcb1

Please sign in to comment.