Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

This project aims to explore how NEST works with Elasticsearch in .NET 5 projects.

License

Notifications You must be signed in to change notification settings

AntonioFalcaoJr/Dotnet5.Elasticsearch

Repository files navigation

.NET 5 + Elasticsearch + NEST

.NET Core

This project aims to explore how NEST works with Elasticsearch in .NET 5 projects.

Getting Started

After the project clone follow the steps described in the installing.

HTTPS

git clone https://github.com/AntonioFalcao/Dotnet5.Elasticsearch.git

SSH

git clone git@github.com:AntonioFalcao/Dotnet5.Elasticsearch.git

Prerequisites

To check this functionality:

dotnet --version

For more details

dotnet --info
  • Docker - The container platform used

To check this functionality:

docker --version

Installing

With the use of containerization, we can practically orchestrate the necessary infrastructure.

You will need an Elastic Search cluster + Kibana , to meet the need for Search Engine, so you must run the respective docker-compose on your Elasticsearch server.

cd ./.elasticsearch/
docker-compose up -d

Is important to say, if occurrence problems with max virtual memory area:

docker logs es01

# abbreviated

ERROR: [1] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

It's possible to increase to at least [262144]:

sudo sysctl -w vm.max_map_count=262144

More details about in this link

The Kibana service will be available in default host http://localhost:5601, as defined on compose.

  kib01:
    image: docker.elastic.co/kibana/kibana:7.6.0
    container_name: kib01
    ports:
      - 5601:5601
    environment:
      ELASTICSEARCH_URL: http://es01:9200
      ELASTICSEARCH_HOSTS: http://es01:9200

# abbreviated

App settings

After providing the necessary infrastructure, we need to define the cluster index and nodes addresses on the appsettings from the Elasticsearch.Client.WebApi project.

{
  "Elasticsearch": {
    "index": "card",
    "node1Uri": "http://192.168.0.27:9200/",
    "node2Uri": "http://192.168.0.27:9201/",
    "node3Uri": "http://192.168.0.27:9202/"
  }
}

And then set the HTTP client host on appsettings from Elasticsearch.Stressor.WebApi project.

{
  "ElasticsearchClient": {
    "Url": "http://localhost:5000"
  }
}

Running

The respective compose provide the client and stressor services:

docker-compose up -d

Stressor and Client services

The Stressor service provide resources to request generate, modify, and remove data from Elasticsearch through the client service.

Is just run the compose from the app to up both of then in the same network. In this way is possible to use services names on the appsettings.

The Client routing uses the default http://hostname:port/api/v{version}/controller,
where /v1 is Synchronous and /v2 is Asynchronous.

The Stressor routing uses the default http://hostname:port/controller/action.

To make API calls, you can use the file ./basic-api-call.http through extension REST Client:

# STRESSOR
###
GET http://localhost:6000/stressor/generate?amount=10
###
GET http://localhost:6000/stressor/modify?amount=10
###
GET http://localhost:6000/stressor/exclude?amount=10
# CLIENT
###
GET http://localhost:5000/api/v2/card
###
GET http://localhost:5000/api/v2/card/f694491b-bc98-45bc-af97-67f7ac460908

Built With

.NET Stack

Elasticsearch Stack

  • Elasticsearch - Search Engine used.
  • NEST - Elasticsearch client for .NET
  • Kibana - Elasticsearch visualize and analyze service

Contributing

Available soon!

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details

Acknowledgments

  • Nothing more, for now.

About

This project aims to explore how NEST works with Elasticsearch in .NET 5 projects.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published