From 5d6fd1f3f91ea9a238534622b7eac99799a774e0 Mon Sep 17 00:00:00 2001 From: AmasiaNalbandian Date: Thu, 16 Dec 2021 12:41:34 -0500 Subject: [PATCH] changed description for advanced search --- src/api/search/src/search.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/api/search/src/search.js b/src/api/search/src/search.js index 840c90055b..0ae964b503 100644 --- a/src/api/search/src/search.js +++ b/src/api/search/src/search.js @@ -78,17 +78,17 @@ const search = async ( /** * Advanced search allows you to look up multiple or single fields based on the input provided - * @param postText - text to search in post field - * @param authorText - text to search in author field - * @param titleText - text to search in title field - * @param dateStart - published after this date - * @param dateEnd - published before this date + * @param options.post - text to search in post field + * @param options.author - text to search in author field + * @param options.title - text to search in title field + * @param options.from - published after this date + * @param options.to - published before this date * @return all the results matching the fields text * Range queries: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_ranges * Match field queries: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-ppmatch-query.html#query-dsl-match-query-zero */ const advancedSearch = async (options) => { - const query = { + const results = { query: { bool: { must: [], @@ -96,7 +96,7 @@ const advancedSearch = async (options) => { }, }; - const must = query.query.bool.must; + const { must } = results.query.bool; if (options.author) { must.push({ @@ -149,6 +149,7 @@ const advancedSearch = async (options) => { if (!options.page) { options.page = 0; } + const { body: { hits }, } = await client.search({ @@ -157,7 +158,7 @@ const advancedSearch = async (options) => { _source: ['id'], index, type, - body: query, + body: results, }); return {