oscklmO
Convex Community3y ago
12 replies
oscklm

Weird behaviour with search, all of a sudden my search result is not the same with same search term

I just came back after about and hour, and continued working on my app. Now the search results are not the same as before? I've doubled checked all the obvious things that could be wrong, like the query indexes not being met etc.

export const search = query({
  args: {
    search: v.string(),
  },
  handler: async (ctx, args) => {
    const videos = await ctx.db
      .query('video')
      .withSearchIndex('search_title', (q) =>
        q
          .search('details.title', args.search)
          .eq('isApproved', true)
          .eq('privacy', 'public'),
      )
      .take(20)

    return videos
  },
})


The search index:
.searchIndex('search_title', {
    searchField: 'details.title',
    filterFields: ['isApproved', 'privacy'],
  })

Here is a snippet from the specific video document i'm no longer able to get a search result for, even though i was 1 hour ago, when i searched for example for "10 ting" or "pap & lim" which worked perfectly before?

{
  "_creationTime": 1705061346057.3284,
  "_id": "rx7d7yd7v2xdgzmyxnr7ht4ghh6hcjqb",
  "details": {
    "category": "Underholdning",
    "description": "Sådan laver du fede ting med pap og lim",
    "tags": ["wow", "pap", "og", "lim", "diy", "kreativ"],
    "title": "10 ting du kan lave med pap & lim og en masse"
  },
  "isApproved": true,
  "privacy": "public"
}
Was this page helpful?