fix for 404 on empty search results

This commit is contained in:
keyan 2024-01-19 15:12:47 -06:00
parent 64e49934d4
commit c41ad5d469
1 changed files with 16 additions and 2 deletions

View File

@ -146,6 +146,13 @@ export default {
return `(${e._source.id}, ${i})` return `(${e._source.id}, ${i})`
}).join(',') }).join(',')
if (values.length === 0) {
return {
cursor: null,
items: []
}
}
const items = await itemQueryWithMeta({ const items = await itemQueryWithMeta({
me, me,
models, models,
@ -342,7 +349,7 @@ export default {
const whenRange = when === 'custom' const whenRange = when === 'custom'
? { ? {
gte: whenFrom, gte: whenFrom,
lte: new Date(Math.min(new Date(whenTo), decodedCursor.time)) lte: new Date(Math.min(new Date(Number(whenTo)), decodedCursor.time))
} }
: { : {
lte: decodedCursor.time, lte: decodedCursor.time,
@ -366,7 +373,7 @@ export default {
function_score: { function_score: {
query: { query: {
bool: { bool: {
...(sort === 'recent' ? { must: termQueries } : { should: termQueries }), must: termQueries,
filter: [ filter: [
...whatArr, ...whatArr,
me me
@ -421,6 +428,13 @@ export default {
return `(${e._source.id}, ${i})` return `(${e._source.id}, ${i})`
}).join(',') }).join(',')
if (values.length === 0) {
return {
cursor: null,
items: []
}
}
const items = (await itemQueryWithMeta({ const items = (await itemQueryWithMeta({
me, me,
models, models,