Skip to content

Commit

Permalink
changed description for advanced search
Browse files Browse the repository at this point in the history
  • Loading branch information
AmasiaNalbandian committed Dec 16, 2021
1 parent ad0209e commit 5d6fd1f
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/api/search/src/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,25 @@ 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: [],
},
},
};

const must = query.query.bool.must;
const { must } = results.query.bool;

if (options.author) {
must.push({
Expand Down Expand Up @@ -149,6 +149,7 @@ const advancedSearch = async (options) => {
if (!options.page) {
options.page = 0;
}

const {
body: { hits },
} = await client.search({
Expand All @@ -157,7 +158,7 @@ const advancedSearch = async (options) => {
_source: ['id'],
index,
type,
body: query,
body: results,
});

return {
Expand Down

0 comments on commit 5d6fd1f

Please sign in to comment.