vue.js - 从 vue 客户端使用 mongoose 进行模糊搜索

标签 vue.js mongoose fuzzy-search feathersjs

获取错误未知的顶级运算符 $regex

搜索.vue `

let questDocuments = await conversation
        .find({ query: { $limit: 100, $search: q, skippop: true } })
        .then(response => {`

q 是被传递的字符串

服务 Hook

before: {
    all: [],
    find: [
      hookBeforeFind,
      search({
        fields: ["label"],
        deep: true
      })      
    ],

模型

const conversation = new Schema(
    {
      label: { type: String, required: true },
      nodeId: { type: String, required: true },
      details: { type: String },
      url: { type: String },
      creator: { type: String },
      handle: { type: String },
      date: { type: String },

从搜索栏添加表达式进行搜索。例如“那个”

最佳答案

将$regex 添加到whitelist option Mongoose 服务:

app.use('/messages', service({
  Model,
  whitelist: [ '$regex' ]
}));

关于vue.js - 从 vue 客户端使用 mongoose 进行模糊搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54676962/

相关文章:

mysql - 根据给定的词群,根据 OCR 错误自动构建可能词的输出列表

fuzzy-search - 如何在大型字符串数据库中找到字符串的最佳模糊匹配

javascript - 如何使用 Lodash java 脚本库进行模糊搜索?

vue.js - 如何让 Nuxt.js 和裸 Vue.js 项目共享组件

javascript - 在 Created 或 Mounted Hook 中访问组件数据

google-maps - 如何使用 VueJs 在 Google map 中添加我的位置按钮?

vue.js - 如何从 vuetify 上的多个日期选择器获取日期?

javascript - Mongoose 检索仅插入推送

arrays - MongoDB 中每年和每月的聚合

arrays - 如何将新值推送到 Mongoose 中的嵌套数组