1 00:00:02,210 --> 00:00:05,120 Let's now come to evaluation 2 00:00:05,150 --> 00:00:11,060 operators. Now json schema is something I covered in the document schema module, 3 00:00:11,060 --> 00:00:15,560 you could also use it in a query to find elements that have a certain document schema, 4 00:00:15,590 --> 00:00:22,440 so you set up a schema there as a value just as shown for validation. Mod is the modulus operator, 5 00:00:22,460 --> 00:00:30,080 so here you could basically divide a field value with a certain number and then check if the result 6 00:00:30,620 --> 00:00:33,700 is ok for you. Text is something 7 00:00:33,700 --> 00:00:40,720 I'll come back later in the indexes module where it's deprecated and basically replaced with expression, 8 00:00:40,730 --> 00:00:44,140 so in the next lectures we'll have a look at expression and regex 9 00:00:44,270 --> 00:00:46,110 and let's start with regex. 10 00:00:46,280 --> 00:00:55,090 Regex allows you to search for text and for that, I'll switch back to my movie data database 11 00:00:56,060 --> 00:00:58,730 and run some query on my movies, 12 00:00:59,060 --> 00:01:03,490 remember if we quickly find one, there we also have a summary field. 13 00:01:05,040 --> 00:01:10,410 Now let's say we want to search for a text snippet in there, we want to search for a musical just because 14 00:01:10,410 --> 00:01:11,410 I see it here. 15 00:01:11,760 --> 00:01:15,740 Now what we could of course think that it will work is that 16 00:01:15,750 --> 00:01:26,910 we access our movies and then we find all movies where summary, that was the field name is equal to musical. 17 00:01:27,450 --> 00:01:31,900 But if I do it like this, I find no entries because this looks for full equality, 18 00:01:31,980 --> 00:01:38,880 so it would find all documents where summary is exactly equal to musical, written like this. Well musical 19 00:01:38,880 --> 00:01:42,210 is just one word in there though and not the complete entry, 20 00:01:42,510 --> 00:01:43,860 so this does not work. 21 00:01:44,280 --> 00:01:50,490 Now for finding text snippets, the most efficient way of doing it is to use a text index, something you 22 00:01:50,490 --> 00:01:52,830 will learn about in the indexing module 23 00:01:53,130 --> 00:01:59,160 but if you don't have such an index, you can't use one or you only have very short text snippets which summary 24 00:01:59,160 --> 00:02:00,800 is already a bit above to be honest 25 00:02:00,810 --> 00:02:09,430 but let's still use it, then you can use regex query but be aware that it will not be super performant. 26 00:02:09,630 --> 00:02:16,400 So what you could do here is you can specify $regex and regex stands for regular expression 27 00:02:16,550 --> 00:02:23,960 which is a way of searching text for certain patterns. Now you can dive deeper into regex, setting 28 00:02:23,960 --> 00:02:26,300 up these patterns can be quite complex, 29 00:02:26,300 --> 00:02:27,820 we'll keep it simple here, 30 00:02:28,010 --> 00:02:35,400 a pattern is always surrounded by forward slashes and in-between you define your pattern. The simplest pattern 31 00:02:35,400 --> 00:02:36,300 possible 32 00:02:36,340 --> 00:02:38,030 is that you just type a word 33 00:02:38,330 --> 00:02:46,010 and now this will not look for full equality but it will look for this word in all the summaries and 34 00:02:46,010 --> 00:02:51,320 return all documents where in the summary, this word can be found. 35 00:02:51,800 --> 00:02:53,280 So if I now hit enter, 36 00:02:53,720 --> 00:02:58,990 now we find this item here where we see musical here 37 00:02:59,440 --> 00:03:03,860 and note that it's a different item than we saw before because if I scroll up, 38 00:03:03,950 --> 00:03:07,230 then here we have that musical comedy we saw earlier. 39 00:03:07,370 --> 00:03:12,900 So this is regex, nice for searching text but not the most efficient way of doing that, 40 00:03:12,980 --> 00:03:18,000 hence definitely have a look at the text index in the indexes module. 41 00:03:18,050 --> 00:03:19,520 Now that was regex, 42 00:03:19,520 --> 00:03:21,440 now what does expression do?