Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To install Elastic search as a windows service follow Elastic search documentation

The service is going to run from the folder you run the command from. Thus you should properly move it into a dedicated “services” folder like the one you creates from the DC PowerShell script.

https://www.elastic.co/guide/en/elasticsearch/reference/8.1/zip-windows.html#windows-service

...

Once this has been edited, start the installed service

Alternatively running the following command also starts the service

Code Block
elasticsearch-service.bat start

Reset the password for the elastic user

...

If Elastic is installed and runs correctly, you should see something like this

...

Generate an API key in Postman

In order to actually use Elastic, you must generate an API key. This is done using their API.

...

Using Postman this can be done using the following steps

  1. Make a new POST request with the following url http://localhost:9200/_security/api_key

  2. In the Authorization Params tab, chose Basic Auth in the Type dropdown.

  3. Put in the Elastic username and password used the previous steps

  4. In the Body Params tab, chose Rawi in the selection and JSON in the dropdown

  5. Put in the following body

    Code Block
    {
      "name": "my-api-key"
    }

  6. Execute the request

This should give you the following response

...

Info

The API key to use is the encoded key in the response

Generate an API key in Powershell

Code Block
languagepowershell
$body = @{
    "name"  = "my-api-key"
}
$username = "elastic"
$password = ""
$securePwd = ConvertTo-SecureString $password -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ($username, $securePwd)

$url ="http://localhost:9200/_security/api_key"
Invoke-RestMethod -Method 'Post' -Uri $url -Body ($body|ConvertTo-Json) -ContentType "application/json" -Credential $cred

...

Insert the API key in the appsettings.json

...