 Good afternoon. Good morning. Today we're going to be talking about Super Sush with Open Sush and Python. My name is Laiso Shoah So a little bit about me. I work for Ivan actually at Ivan we manage OpenSush databases and I really like Python I worked with Python for a long lot of years and I happened to live in the city of Munich and I decided to organize Paleris Munich chapter there You can follow me if you want to know more about Python events. I'm always attending So today what we're gonna be talking we're gonna be talking about what is OpenSush? Why should you consider OpenSush in your project? And I will also Show you how to write some search queries in a live demo. So wish me luck because live demos are most never work So what is OpenSush? If you are familiar with Elastic Sush, OpenSush is a directive work of Elastic Sush version 7.10 it actually has been a year and Now OpenSush is in the version 2 already and they do monthly releases kind of yeah It's very frequently the releases for OpenSush If you don't if you're not familiar with Elastic Sush, OpenSush is also okay. I'll also explain you that So OpenSush has it has in the name is OpenSush and it's also a search engine name It has support for REST API So if you are a backend developer or front-end Maybe you already familiar with it and you don't need the extra language to deal with OpenSush But it does have support for many languages in Python. Python is one of the Go PHP and Java It also offers you analytics suite I think it's a fancy word to tell you that you can actually draw some insights from your code or from your data and with the OpenSush dashboards and A lot of companies actually use OpenSush not for such engine But to analyze the logs so they kind of send the logs there and it gives you a great overview Very very fast open source very fast. So why should you consider OpenSush? When I think about OpenSush, I try to actually focus in the superpower of OpenSush So if you think OpenSush would be a super hero, what kind of super hero would OpenSush be? So I would say that OpenSush would speak several languages because it does have support for more than 30 languages So for example, not programming languages human languages like German Spanish Portuguese So when you're sending your data to OpenSush, you can specify which language it will be It's defined for and it will optimize for search. I Also, thank you for message would be a hero. It would be able to Read your mind Because you can you can implement auto completion. I think this is something that you may have seen In search engine is you are typing something and kind of tells, okay Maybe this person is looking for this based on your relevance or some information about to you So this is something that you can also do with OpenSush And if you think that OpenSush could understand so many languages more than 30 The question would be can OpenSush understand my broken English? The answer is yes because you do have fuzz searching. So even if you mistype something or yeah If you have small mistakes OpenSush is still will be able to bring your results and if you're familiar with Different databases that actually you have to provide a mapping or some sort of definitions from the beginning With OpenSush, you have something called dynamic mapping. What is that with dynamic mapping? It actually you can just send your data to OpenSush And it would Figure out what kind of field is in the data. Is it a text? Is it a float or any kind of material? So but you can also define you so you have this flexibility. So it's quite cool So this would be some of the reasons. I would say why you should consider OpenSush in your projects Now I'm gonna go over some search queries Actually for that I have we're gonna be using the Python OpenSush client Lots of data We are most in the lunch. So I pick up some lunch some recipes for us to work and You can find it here in this repository You can scan the QR code or you can just go in the GitHub and work it The data looks a bit like this So you can see the directions like how to prepare the food and there are several fields here like data Categories, etc, etc So I will show you now if you go to the repository you can see it here in the read me Where did I take this data from? What kind of support is there or what kind of queries I have it here So I took the data from the K go recipes and you can also take it from there And yeah, you can see it here how to install and how to get started. So for our first I already have our open search cluster running So I'm not gonna set up everything and I already sent the data, but it's also you can find it here in the repository How did I do this? So now I will focus on the queries the first one that I decide to Look for so actually you can just go here and look for help and it will show up what kind of Queries we have it here. So let's go to the first one is the magic query So if I look for here and I look in the match and in the match, I'll be looking in the title For something very exotic. So the most exotic thing I could think about was chocolate and garlic So that's what recipe that we're gonna try to find out I'm not sure who would eat this, but I think I would eat this actually. I like to try new things So let's see if you find out something here So if I press enter and you can see it here that actually I do find some recipes The first one is chocolate garlic like a toaster bread and the other ones are just have garlic on the title You must be wondering like, okay, if I'm looking for chocolate garlic, why is that I'm getting just recipes with garlic? The question the answer is that when you're working with the match queer There is an operator that by default uses or so actually what is doing is looking for chocolate or Garlic or chocolate garlic and it will bring those results based in score. So that's why the first one is actually the most That has the two words, but if you we want actually to find Only chocolate and garlic. We could also define the operator and That's what I will do now. Whoops here So you can see that I came I found out. Yeah, there is just one and I will definitely try You must be wondering like what is the syntax? I will also show you so in the match square The syntax kind of looks like this. So I do have open search client and there is a method called search And I have to specify which kind of index I'll be looking for and I write the body with the query Which is a Python dictionary and here I define which kind of queries which is the match one and which field I'm looking for this and Chara, we have it here chocolate garlic. I have a specified the end operator here. So it's pretty straightforward Now be one you must be wondering for example if I try out here if I change the Position between chocolate and garlic I start with garlic and finish with chocolate would I will still get some Matches do you think I've still got some match? Can you raise the rent? Okay, I think everybody knows a lot But yes You would get some at you still got the same one that we saw The thing is with the match the position of the words that you are looking. They are not important They are not so relevant. You still will bring results but in some case for example if you are looking for someone's name in a database and If you switch the surname of the name Maybe you end up with someone different So in some cases you do want to consider in the order of your query So for that you will use my phrase and I will show you with an example. What is the match phrase? So if I have here search that pie match oops match phrase and I'll be looking title and I can define what I'm going to be looking for for example if I'm looking for cake coconut and We're gonna see what we can find Actually, we don't find anything here, but I wonder okay. I do have 20,000 recipes I didn't find anything correct here because in the match phrase here has it is right now It is looking exactly for those words in this order nothing between Nothing swapped anything. So of course if I Correct that for coconut cake with the right word in English. I Can see some results and this makes sense, right? But yeah, even if you still want to see like okay The relevance of the is a bit important and but I wonder okay. Can I give some flexibility to the match phrase? Yes, so in this case if we want to correct the previous one and give some flexibility in the match phrase There is something called slope parameter So if they slow parameter works like this it allow it's the allowed distance between the words in this case By default is zero. So it means that this words have to be in this order to actually bring some result, but if I If I actually now give a slope of one It should work. So yeah, actually here you can see that now I found cake with coconut and so on if I give a slope of two It also works and now we have even more because I'm giving more flexibility how this position of these words would be But I'm a very visual person and even with this maybe it's a bit confusing. What is actually the slow parameter? so I will show you what's this little parameters of here is a document that we quit when we queried and This is our query. So in this case if we try to identify slope has one What we but it tries to do is actually, okay Let me see a combination of this if I change the position of one of this word would still work Yes, so basically the coconut could be in position three and the distance would be just one and it would work Another example could give you is like that. I fix the coconut cake or the cake coconut Because they are swapped. So if actually I try with a slope of two if you will bring the Position two to the position one and the position one to the position two and then you will find it So, I hope this was a piece of cake to understand It's pretty interesting this kind of flexibility because you don't expect always that the reader Rides exactly what they want. So it's important to give this flexibility Now we'll be talking about fuzzness and for that I Try to think about an example that it's a bit complicated for me sometimes for example the I'll be using the match one and I'll be looking in Taito For something that sometimes it can get wrong like the word dessert So that is desert and that is dessert and they're very similar They even sound similar when you say it but one is salty I guess and the other one is sweet So if I try to mistype here and look for for it. So if I'm looking for desert here, I Will probably not find anything because it's incorrect word, but there is something called like fuzzness Which we can define. Let me see if I wrote correct Has won for example and now we can actually find something because the difference between desert and Dessert is one s. So the fuzzness if you configure it to one you will be able to get some results How would it like be in a more conceptual way or like more general one? So for example, if words are different or for example, if you Remove words or actually increase words. This all count has one distance It's it uses something called lever Stein distance to actually calculate this but it's pretty straightforward is about this last one is about transpose of two Letters that are close to each other for example And this is how you calculate the fuzzness But you know, I think sometimes like you just have your data. You don't know what is How many mistakes are there? What would be the best way? Actually, there is a parameter called auto that I've also show you that you can do that for easily So he is like how the syntax works You have the match and you have the title and in this case, you have the query and you give the fuzzness and Then you can also put auto so in this case if I actually have it here has with auto It will automatically look for what it would be the best fuzzness to be used Depending on the size of the word. So for long words, we're gonna be use a little bit more and for smaller words a bit a bit less This is important to notice that If you don't configure your fuzzness, correct You may end up with no relevant results because if you swap everything It may become an another word and it's not relevant for you The last one that I want to show you is actually I want to try to find out one recipe with a Guinness I know you can't drink it, but can you cook with it? So let's see if we can find something so I would just use the match one again and Actually, I have to specify the file and that was match and that was title and Look for the word Guinness, which I hope I write correct If I'm not you have to tell me But yes, so for example, this one is quite simple I'm just looking for Guinness and match where it to use it gives you they scored So you see it here. There's more starter which probably not nice But there are some cakes too here. So I think that's It but I have just to show you dashboards. So open search also have open search dashboards would be similar to the Kibana ones but yes, looks like this you can Draw visualizations out of the box and you can also do queries from there without any with first API for example So that's it for today and you can find the demo here. Yes Thank you Okay, so thank you very much for the talk. We do have time for questions and again, just Come to the microphone so that people watching online can also hear it and people on back. So Do you know what the differences between elastic search and open search From the version 7.10, they are the same but since then they are different projects and they are developing different So actually I didn't look so much in the chain of log of elastic search more. What was the last release of open search? Thank you So do you have any other Question in the rock. Yes. So you are seeing that we can replace elastic search with open search It's a question, right? It depends of your user case because there are some plugins or some things that they didn't allow Compatibility so it really depends what kind of tools are you using but from the client if you are using the Another way to migrate it like if you're writing in the latest one and one You have to go back from last search version 7.10 and then do the migration to open search 100 and then go to open search to 0 0 that would be what I would do if I would be migrating clients Okay Okay Actually open search maintainer is also here. So if you have more questions you can also talk with him He's right there Yes, thank you for your contribution So Do we have any other other question? Yeah, you have a few minutes. No, it's okay So if you want to talk with me, we can also talk after the talk. Thank you very much