-
First, let's go ahead and dive into the pricing page. And if we just scroll on down, there is this open source section right here with a Get Started button. We can click on that.
-
And we're taken to a list in their documentation with instructions. From here, I'm going to go ahead and just switch on over to my terminal and we'll get going from there. So the first thing that we're going to want to do
-
is make a directory to help us get started. So I'm going to go ahead and create a directory is make a directory to house our MeliSearch project.
-
So I'm going to call this MeliSearch and then we can go ahead and cd into it. Great. From there, we can go ahead and run curl with a hyphen capital L
-
and point that to HTTPS, semicolon slash slash, install.melisearch.com and then pipe in sh.
-
In case this changes at all in the future, you can also find this on their documentation right here within their setup and installation instructions. But I would imagine that should be pretty consistent.
-
So let's go ahead and run that and it's going to use curl to pull that down. And now if we run LS, you'll see that we have this MeliSearch command right here within our MeliSearch directory.
-
We put this inside of a directory itself because our MeliSearch database is also going to be created here as well. So we'll just keep both of those together inside of a single folder.
-
Once we have that curled down onto our machine, we can go ahead and do dot slash and type in that command's name of MeliSearch
-
and then we'll specify a master key as well for it to create. Now, you will get a warning if your key is less than 16 characters here locally,
-
but in production, it's going to require it to be at least 16 characters in order for you to move onward. So I'm just going to use here locally some master key here
-
and we'll hit enter to run that. And it should set itself up, print out some detailed information about its running status
-
and then activate its logs down here. As we perform searches or indexes against it, we will see additional logs print out down here as well.
-
But what we want to do now is just leave this running here in the background and let's open up a new tab and you want to get into the same directory that we have this command installed at.
-
Now, the master key that we set up with our MeliSearch execution of some master key here is an actual administrative key that we've assigned to our MeliSearch instance.
-
So this is not a key that we're actually going to want to search with from our application. This should be a private key. We really don't even want to use this key for administrative purposes
-
from our AdonisJS application just for MeliSearch commands that we run. As an additional note here, we are setting up MeliSearch for development purposes.
-
So be sure to read through their separate security doc if you're setting this up for production purposes because there's some additional steps that you're going to want to take to ensure your instance here is nice and secure.
-
All right, back over to our new tab. Now, what we want to do is get the keys that we're actually going to utilize inside of our AdonisJS application.
-
So for this, we can use curl yet again with hyphen capital X and perform a get to HTTP semicolon slash slash local host.
-
And then we want to utilize the port that our MeliSearch booted at. And you should see that right here with the server listening on. Mine booted at 7700.
-
So that is the port that I'm going to want to use here. So 7700 and then do slash keys to get back the default keys that MeliSearch created
-
for us to be able to use inside of our application. All right, I'm going to do a backslash there to allow us to go down to a new line because we're also going to want to do capital H to add in a header.
-
And we want to use an authorization header with a bearer token. And the token is our master key. So that's some master key here.
-
And then we'll just pipe in JSON underscore PP for pretty print. And we can run this and we should see printed back to us several different keys.
-
So if I just scroll back up here to the top, by default, we should get four different keys printed back here, each with a different purpose. For example, you'll see that this one here has the ability
-
to perform search actions. And it also has a description of use it to search from the front end. So this is the key that we're actually going to want to use to perform our search operations.
-
The key itself is right here. And it also has a name of default search API key. If we scroll down to the next one, this is our default admin API key.
-
And we want to use it for anything that is not a search operation. This is a secure key. So you want to make sure that you don't expose it anywhere outside of your back end application. In our case, since we're going to server render everything,
-
we're going to be able to keep both of our keys for search and admin purposes inside of our back end and out of the front end altogether. The next one that we get is a read only admin key.
-
And this one too is private. We don't want to expose that. But we can use this one to read just about anything inside of Millisearch. We won't be using that key and we also will not be using
-
this last key here inside of the series. This last one is for chat and search functionalities. So if you are doing chat, which integrates with LLMs and AI,
-
you might want to use this key over just the search key because this one also has permissions to perform those chat operations. We're not going to be utilizing chat at all.
-
So we will use just these first two keys here with search and admin privileges. So we'll keep this handy. And then we'll move on to the next lesson to set up our AdonisJS application.
-
And then we'll plop these keys into our environment variables there.