travis-r6s / gridsome-plugin-flexsearch

Add lightning fast search to Gridsome with FlexSearch
24 stars 7 forks source link

Not working with gridsome upgrade to 0.7.23 #80

Closed rickbsgu closed 2 years ago

rickbsgu commented 2 years ago

Worked famously in prior (old) version. Trying to upgrade side, but the flexsearch plugin not working.

Here's my package.json

{
  "name": "rickb-recipes",
  "private": true,
  "scripts": {
    "build": "gridsome build",
    "develop": "gridsome develop",
    "explore": "gridsome explore"
  },
  "dependencies": {
    "@gridsome/plugin-google-analytics": "^0.1.2",
    "@gridsome/plugin-sitemap": "^0.4.0",
    "@gridsome/source-filesystem": "^0.6.2",
    "@gridsome/transformer-remark": "^0.6.4",
    "gridsome": "^0.7.23",
    "gridsome-plugin-flexsearch": "^2.0.2",
    "v-tooltip": "^2.1.3",
    "vue-moment": "^4.1.0"
  },
  "devDependencies": {
    "autoprefixer": "^9.8.8",
    "gridsome-plugin-tailwindcss": "^4.1.1",
    "postcss": "^7.0.39",
    "tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.2.17"
  }
}

and the flexsearch plugin part of my gridsome.config.js:

    ...
    {
      use: 'gridsome-plugin-flexsearch',
      options: {
        collections: [
          {
            typeName: 'Recipe',
            indexName: 'Recipe',
            fields: ['title', 'path', 'image', 'description']
          }
        ],
        searchFields: ['category', 'title', 'content'],
        encode: "balance",
        tokenize: "strict",
        threshold: 0,
        resolution: 3,
        depth: 3
      }
    },
    ...

I tried removing the args after 'searchFields', with no change.

rickbsgu commented 2 years ago

Hmm. I'm reading change notes I found here that suggests it might have something to do with the v1.0.0 changes.

It's been a long while since I looked at this, so I'm having to sift through the source, again.

I think the relevant piece is this:

        ...
         <template
            v-for="(recipe, ix) in searchResults">
            <RecipeItem :key="ix" :recipe="recipe" />
          </template>
          ...

Looking at it...

rickbsgu commented 2 years ago

Ok, I realized what was happening. Got caught by a couple of upgrade changes. Is working good.