Skip to content

Commit

Permalink
feat(scanr-agg): allow empty query
Browse files Browse the repository at this point in the history
  • Loading branch information
ahonestla committed Dec 18, 2023
1 parent 3e08b14 commit 2ab106b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion client/src/pages/home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export default function Home() {
<Row gutters>
<Col>
<Button
onClick={() => (formQueries.length === 0 ? setFormIsError(true) : (setFormIsError(false), refetch()))}
onClick={() => ((formQueries.length === 0) && (formDatasource !== 'scanr-agg') ? setFormIsError(true) : (setFormIsError(false), refetch()))}
>
Generate graph
</Button>
Expand Down
5 changes: 3 additions & 2 deletions server/src/routes/scanr-agg/make-query.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export const makeQuery = (queries, condition, startyear, endyear, size = DEFAULT
filter: [
{ range: { year: { gte: startyear, lte: endyear } } },
],
must: {
...(queries.length > 0
&& { must: {
query_string: {
fields: [
'title.*^3',
Expand All @@ -23,7 +24,7 @@ export const makeQuery = (queries, condition, startyear, endyear, size = DEFAULT
.join(` ${condition} `),
phrase_slop: 0,
},
},
} }),
},
},
aggs: {
Expand Down

0 comments on commit 2ab106b

Please sign in to comment.