Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature - Elastic Search Suggestions #2853

Merged
merged 3 commits into from
May 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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