Start a new topic

Create a Textsearch


i've read a lot of the mongoDB documentation and the Kinvey Docs, but i'm not able to build a "cool" search function for my collection - so maybe you can help me out. My problem is that kinvey seems to not support all stuff from mongo directly, so i'm a little bit confused.

Let's say i have to fields in my user collection
"first_name" and "last_name"  - and now i want to create a search function for this. Of course i should be possible to search for "John" as for "John Smith". (If there are more persons with the same first_name, "john" as a term should deliever all of them as result)

I've tried something like this:


if(searchTerm.indexOf(' ')!= -1){
        var terms =  searchTerm.split(' ');
        firstName = terms[0];
        lastName = terms[1];
        re_first_name = new RegExp(regExpEscape(firstName), "i");
        re_last_name = new RegExp(regExpEscape(lastName), "i");
        query = {
          $and: [
            { first_name: { $text: re_first_name } } ]
          //  { last_name: { $regex: re_last_name } } ],
        firstName = searchTerm;
        re_first_name = new RegExp(regExpEscape(firstName), "i");
        query = {
          first_name: { $regex: re_first_name }


but that doesn't seem to be pretty nor to be right. Any ideas? Maybe an addition in the docs would be nice, i think a "text search" is one of the basics we are dealing with ?!

best, Nico


Can you please be a bit more specific as to what you're trying to do here?  I'm very confused.   

You can use collectionAccess: along with find (see former link) and not have to write your own search...


Hey Damien,

i've read along the mongo docs, that there is a index functionality for textfields to search through them - this doesn't seem to be available through Kinvey Backend. Is this right?


Nico, we do not suppose full-string searching or Case - Insensitive searching at the time.  Only front-anchored case sensitive searches.


Login or Signup to post a comment