Find() query a mongoDB aggIndex with LIKE operator containing pipe "|" character
Use something like this: db.getCollection("YOURTABLE").find( { aggIndex : /^FIRST_INDEX\|SECOND_INDEX.*/i } );
When we have a pipe character: | and we try to find() something with this pipe, the mongoDB shell understand it's like an OR statement. So we just have to add "\" before the pipe |.
For LIKE I used /^TEXT.*/i and it works great!
Using LIKE (SQL): aggIndex LIKE 'FIRST_INDEX|SECOND_INDEX%';
LIKE in MongoDB: aggIndex : /^FIRST_INDEX\|SECOND_INDEX.*/i
The /^ determines the beginning. The .*/i determines that we shall have more characters after this point, independently if they are lower or upper case. It works for deleteMany() too.
When we have a pipe character: | and we try to find() something with this pipe, the mongoDB shell understand it's like an OR statement. So we just have to add "\" before the pipe |.
For LIKE I used /^TEXT.*/i and it works great!
Using LIKE (SQL): aggIndex LIKE 'FIRST_INDEX|SECOND_INDEX%';
LIKE in MongoDB: aggIndex : /^FIRST_INDEX\|SECOND_INDEX.*/i
The /^ determines the beginning. The .*/i determines that we shall have more characters after this point, independently if they are lower or upper case. It works for deleteMany() too.
Comments
Post a Comment