lunr-module icon indicating copy to clipboard operation
lunr-module copied to clipboard

Adding fuzzy search

Open sandoche opened this issue 3 years ago • 1 comments

sandoche avatar Oct 25 '21 10:10 sandoche

As a workaround, I implemented this fix by extending the LunrSearch component:

<script>
import LunrSearch from 'lunr-module/search'

export default {
  extends: LunrSearch,
  methods: {
    async search (txt) {
      if (!this.searchIndex) {
        const indexLoaded = await this.loadIndex()

        if (!indexLoaded) {
          return
        }
      }

      this.setStatus('searching')

      txt = txt + '* ' + txt
      this.searchResults = this.searchIndex.search(txt)

      if (!this.searchResults || !this.searchResults.length) {
        this.setStatus('noresults')
      } else {
        this.clearStatus()
      }

      this.openResults()
    },
  }
}
</script>

Decipher avatar Feb 19 '22 22:02 Decipher