Rethinkdb full search by contains text

668 Views Asked by At

I have a lot of tries to search by same part of the string in the rethinkdb but I can not do it yet. And I receive this error:

db.table("jobs")
        .filter(db.row("title").contains(title))
        .filter({ locationCode: location })
        .run()
        .then(result => {
            res.json({
                result,
                meta: {
                    title,
                    location,
                    count: result.length,
                },
            });
        });

Error:

Unhandled rejection ReqlLogicError: Cannot convert STRING to SEQUENCE in:
r.table("jobs").filter(r.row("title").contains("front")).filter({
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  locationCode: "216"
})

And I'm using the rethinkdbdash library. please help me to solve this problem.

2

There are 2 best solutions below

0
On BEST ANSWER

Use the downcase and match instead of contains is worked for me:

.filter(db.row("title").downcase().match(title.toLowerCase()))
0
On

contains is used to check if an element is present in a sequence

match is to be used when you do string search