Is it possible to use ZQ's fuzzy search plugin on just a list of texts? Meaning it has no field to search other than the text itself?

I need to make a fuzzy search over a list of texts, that’s it, just a list of plain texts.

For some reason ZQ’s plugin does not recognize the text data type.
Is there an alternative?

I’m tagging @ZeroqodeSupport so they are aware of the question!

1 Like

Hello sdcuru97,

Thank you for reaching out!
I went through the ZQ Fuzzy Search and Autocomplete Plugin documentation here, and it seems that searching over a list of plain texts is not currently supported.

I also checked the Fuzzy Search Pro Plugin documentation here, and unfortunately, it too does not offer this feature at the moment.

Let me know if I can assist you with anything else!

Thank you for the tag fede.bubble :folded_hands:

Best regards,
Zeroqode Support Team
Browse all Zeroqode Plugins for Bubble
Banner_Last3

I don’t know if it helps, but in my case, I created (ChatGPT) an API on Google Cloud Run where I send the searched text and the list of texts where the search will be performed, and it returns the 50 matching items.

I don’t know if this would be a solution for you.

import express from 'express'
import cors from 'cors'
import Fuse from 'fuse.js'

const app = express()
app.use(cors())
app.use(express.json())

// Remove acentos e converte para minúsculo
const normalize = str =>
  str.normalize('NFD').replace(/[\u0300-\u036f]/g, '').toLowerCase()

app.post('/buscar', (req, res) => {
  const { lista, texto, limite } = req.body

  if (!Array.isArray(lista)) {
    return res.status(400).json({ erro: 'Lista deve ser um array' })
  }

  // Se texto for vazio ou apenas espaços, retorna lista vazia
  if (!texto || texto.trim() === '') {
    return res.json({ resultados: [] })
  }

  const LIMITE = Math.max(1, Math.min(100, parseInt(limite) || 50))

  // Remove duplicatas por ID
  const listaSemDuplicatas = Array.from(
    new Map(lista.map(item => [item.id, item])).values()
  )

  // Normaliza os textos para busca
  const textoNormalizado = normalize(texto)

  const listaNormalizada = listaSemDuplicatas.map(item => ({
    id: item.id,
    textoOriginal: item.texto,
    textoNormalizado: normalize(item.texto)
  }))

  const fuse = new Fuse(listaNormalizada, {
    keys: ['textoNormalizado'],
    includeScore: true,
    threshold: 0.4,
    ignoreLocation: true,
    minMatchCharLength: texto.length
  })

  const fuzzyResultados = fuse.search(textoNormalizado)

  const filtrados = fuzzyResultados
    .filter(item => item.item.textoNormalizado.includes(textoNormalizado))

  const ordenados = filtrados
    .sort((a, b) => {
      const diff = a.score - b.score
      if (Math.abs(diff) > 0.001) return diff
      return a.item.textoOriginal.localeCompare(b.item.textoOriginal)
    })
    .slice(0, LIMITE)
    .map(item => item.item.id)

  return res.json({ resultados: ordenados })
})

const PORT = process.env.PORT || 8080
app.listen(PORT, () => {
  console.log(`API de busca inteligente ativa na porta ${PORT}`)
})

Hey! thank you for your answer. I ended up using a plugin that is especially for this. It is called Fuzzy search and Autocomplete - Text data type. Works like a charm although I will change it in the future because it unnecesarily collects user data.

1 Like

Hi guys, thanks a lot!
I ended up using the only plugin available that allows for text data type. I will change it in the near future because it unnecesariily collects user data.

It would really be a nice feature to have in your plugin, after all, it is the most simple data type to perform a fuzzy search.
However, I understand that the current plugin’s structure is made for working with JSONs rather than text lists.

Has ZQ considered deleting text data type option from the current version of the plugin? It is misleading!

Hello sdcuru97,

We understand that there might be some confusion regarding the plugin’s functionality. To clarify, the plugin works with the ‘text’ data type but does not support ‘list of text’, which is a different data type in the Bubble environment, with its own structure and logic.

We’ve tried to minimize any confusion by explicitly stating this information in the plugin documentation.

If you have any further questions or need additional clarification, feel free to reach out!

Best regards,
Zeroqode Support Team
Browse all Zeroqode Plugins for Bubble
Banner_Last3

This topic was automatically closed after 70 days. New replies are no longer allowed.