skip to Main Content

I tried searching text using the condition { $text: { $search: searchContent } }. This requires a text index. However, text index is not supported by time series . What can I do?

2

Answers


  1. Try using {"field": {"$regex": "value-to-search"}} as your query, this is the closest to a text search without using one, as you mentioned it is not supported and according to the link you provided it probably will not be.

    Login or Signup to reply.
  2. If you know field what you find, you could use $regex same @omercotkd suggest. Here, I use $where for the case that you want to search on all field.

    db.collection.find({
        $expr: {
            $function: {
                body: function(all_field) {
                    for (var field in all_field) {
                        if (all_field[field] == searchContent) return true;
                    }
                    return false;
                },
                args: [ "$$ROOT" ],
                lang: "js"
            }
        }
    })
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search