arve0 / feathers-mongodb-fuzzy-search

Add fuzzy $search to mongodb service.find queries
https://www.npmjs.com/package/feathers-mongodb-fuzzy-search
40 stars 10 forks source link

Error: Can't use $diacriticSensitive with String. #16

Open bruno2kd opened 5 years ago

bruno2kd commented 5 years ago

I'm sorry, I am new to this and I am not sure this is the right place to post.

I am trying to do a diacritic insensitive search:

on the client:

const q = {
                query: {
                    name: {
                        $search: "frénch",
                        $diacriticSensitive: false,
                    },
                },
            };

            const res = await api.products.find(q);

Products hooks:

module.exports = {
    before: {
        all: [],
        find: [
            search({ fields: ["name"] }),
        ],
        get: [],

The error I get:

Error: Can't use $diacriticSensitive with String.
  File "/app/node_modules/mongoose/lib/schema/string.js", line 598, in SchemaString.castForQuery
          throw new Error('Can\'t use ' + $conditional + ' with String.');
  File "/app/node_modules/mongoose/lib/schematype.js", line 1216, in SchemaString.SchemaType.castForQueryWrapper
        return this.castForQuery(params.$conditional, params.val);
  File "/app/node_modules/mongoose/lib/cast.js", line 288, in cast
                  val[$cond] = schematype.castForQueryWrapper({
  File "/app/node_modules/mongoose/lib/query.js", line 4340, in model.Query.Query.cast
        return cast(model.schema, obj, {
  File "/app/node_modules/mongoose/lib/query.js", line 2087, in model.Query.<anonymous>
        this.cast(this.model);
  File "/app/node_modules/mongoose/lib/helpers/query/wrapThunk.js", line 16, in model.Query._wrappedThunk [as _count]
        fn.call(this, cb);
  File "/app/node_modules/kareem/index.js", line 369, in process.nextTick
          process.nextTick(() => fn.apply(this, arguments));
  File "internal/process/next_tick.js", line 132, in _combinedTickCallback
  File "internal/process/next_tick.js", line 219, in process._tickDomainCallback

Mongodb: 3.6v feathers-mongodb-fuzzy-search: 1.1.1v

when I do without the line $diacriticSensitive: false it works right but it is diacritic sensitive. Also, Mongodb docs says that it defaults to diacritic insensitive and it is defaulting for diacritic sensitive for me.

Any clue on what is going wrong?