Hugo Dias
Hugo Dias•2mo ago

Anyone has had issues with search

Anyone has had issues with search indexes filtering on 2 fields ?
.withSearchIndex('by_searchAmount', (q) =>
q
.search('search', args.search)
.eq('teamId', args.teamId)
.eq('amount', args.amount * -1)
)
.withSearchIndex('by_searchAmount', (q) =>
q
.search('search', args.search)
.eq('teamId', args.teamId)
.eq('amount', args.amount * -1)
)
seems to ignore the second filter
17 Replies
Hugo Dias
Hugo DiasOP•2mo ago
actually i think if the full text seach return an entry that is equal to args.amount it actually filters but if not it ignores the filter and return entries with amount != args.ammount very strange
Sara
Sara•2mo ago
q doesn't have .search on it
Hugo Dias
Hugo DiasOP•2mo ago
? q .search('search', args.search) .eq('teamId', args.teamId) .eq('amount', args.amount * -1)
Sara
Sara•2mo ago
like what i mean is you only use these methods on type q
No description
Hugo Dias
Hugo DiasOP•2mo ago
its a search index!
Sara
Sara•2mo ago
oh! my bad! my eyes didn't read the search 🤣 can you share how you indexed the table in your schema?
Hugo Dias
Hugo DiasOP•2mo ago
.searchIndex('by_searchAmount', {
searchField: 'search',
filterFields: ['teamId', 'amount'],
}),
.searchIndex('by_searchAmount', {
searchField: 'search',
filterFields: ['teamId', 'amount'],
}),
amount is a number
Sara
Sara•2mo ago
yep that is strange, I've never encountered this before
Hugo Dias
Hugo DiasOP•2mo ago
any chance i can get a convex eng to look at this?
Sara
Sara•2mo ago
lol I am not one
Hugo Dias
Hugo DiasOP•2mo ago
any way to ping them on this thread?
Hmza
Hmza•2mo ago
@erquhart can you chip in here please?
erquhart
erquhart•2mo ago
Can you log the actual inputs and the result and share here
Hugo Dias
Hugo DiasOP•2mo ago
Hey not right now, but it's literally amount==30 and there no entry with 30 it get ignore and search returns other entries with 26, 29 etc In other queries where theres actual entries with the amount I'm filtering it works
erquhart
erquhart•2mo ago
The logging is important - it basically allows us to determine definitively whether there’s a bug in your code or Convex. Both are understood to work as expected. The logs reveal all 🙂

Did you find this page helpful?