Install Kong Api Gateway on Docker Windows

Today i want to explain how to install Kong Api Gateway on your Windows Docker Desktop.

This is the official guide but there are some error ( )

I have used PostreSQL. In the official guide there is not a “Password” for database and so it do error.

Open a command line and insert this three command.

On your docker desktop client than you must to see the 2 container for database and api gateway.

1. Link Kong to either a Cassandra or PostgreSQL container

docker run -d --name kong-database ^
                -p 5432:5432 ^
                -e "POSTGRES_USER=kong" ^
                -e "POSTGRES_DB=kong" ^

2. Prepare your database

docker run --rm ^
    --link kong-database:kong-database ^
    -e "KONG_DATABASE=postgres" ^
    -e "KONG_PG_HOST=kong-database" ^
    -e "KONG_PG_PASSWORD=kong" ^
    kong kong migrations bootstrap
docker run -d --name kong ^
    --link kong-database:kong-database ^
    -e "KONG_DATABASE=postgres" ^
    -e "KONG_PG_HOST=kong-database" ^
    -e "KONG_PG_PASSWORD=kong" ^
    -e "KONG_PROXY_ACCESS_LOG=/dev/stdout" ^
    -e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" ^
    -e "KONG_PROXY_ERROR_LOG=/dev/stderr" ^
    -e "KONG_ADMIN_ERROR_LOG=/dev/stderr" ^
    -e "KONG_ADMIN_LISTEN=, ssl" ^
    -p 8000:8000 ^
    -p 8443:8443 ^
    -p 8001:8001 ^
    -p 8444:8444 ^

Have fun!

ElasticSearch 5 – NEST Dynamic QueryContainer with QueryContainerDescriptor

How can i create a dynamic QueryContainer with many QueryContainerDescriptor?
How to dynamically build up a Bool query using the NEST client?

I will teach you how to create a dynamic nest query with and logic.

You must to write your QueryContainer:

QueryContainer filters_complete = null;

Then we must to attach to them the many filters that we want

var dateFilter = new QueryContainerDescriptor<OBJTYPE>().DateRange(t => t.Field("student.age").GreaterThanOrEquals(DateTime.Min).LessThanOrEquals(DateTime.Max));
filters_complete &= (new QueryContainerDescriptor<OBJTYPE>().Nested(n => n.Path("student").Query(q2 => q2.Bool(bq => bq.Filter(dateFilter)))));

Add in and another filter to out QueryContainer. Just need to create the other QueryContainerDescriptor

var partial = new QueryContainerDescriptor<OBJTYPE>().Range(t => t.Field("school.alumn_number").GreaterThan(0));
filters_complete &= (new QueryContainerDescriptor<OBJTYPE>().Nested(n => n.Path("school").Query(q2 => q2.Bool(bq => bq.Filter(partial)))));

We have created a query to extract: (student with age >= XX && age <= YY) && (school with alumn number > 0)

Now we must to use it:

string _urlServerElasticSearch = WebConfigurationManager.AppSettings["ElasticSearch_Server"];
var node = new Uri(_urlServerElasticSearch);
var client = new ElasticClient(node);

var response1 = client.Search<OBJTYPE>(s => s
.Query(_ => filters_complete).Scroll("60s").From(0).Size(100)

Use the _ in the lambda expressions, because we don’t care about the parameter!
I use the Scroll() method in my query, if you want to know how to manage the Scroll, see this guide.


Do you know a simplest method?
There is some error in my article?
Or if you have a question write me!


ElasticSearch 5 – How to start using NEST C# .net

In this guide i want to show you how to start in c# .net framework with ElasticSearch version 5, with the library NEST.


Elasticsearch is a Lucene-based search server with Full Text capability, with support for distributed architectures. All features are natively exposed through RESTful interface, while information is handled as JSON documents.
Is a database that contain many table and date, the table are called “index” and the date are called “documents” is like a no-sql database, as mongodb or couchbase.
In each “index” you can load many “documents” with many different “mapping”.

I suggest to install Kibana to manage ElasticSeach. Starter guide.


You can put the mapping on elastic search server throw Kibana dev console.
Mapping is the process of defining how a document, and the fields it contains, are stored and indexed. For instance, use mappings to define:

  • which string fields should be treated as full text fields.
  • which fields contain numbers, dates, or geolocations.
  • whether the values of all fields in the document should be indexed into the catch-all _allfield.
  • the format of date values.
  • custom rules to control the mapping for dynamically added fields.
PUT my_index 
  "mappings": {
    "user": { 
      "_all":       { "enabled": false  }, 
      "properties": { 
        "title":    { "type": "text"  }, 
        "name":     { "type": "text"  }, 
        "age":      { "type": "integer" }  
    "blogpost": { 
      "_all":       { "enabled": false  }, 
      "properties": { 
        "title":    { "type": "text"  }, 
        "body":     { "type": "text"  }, 
        "user_id":  {
          "type":   "keyword" 
        "created":  {
          "type":   "date", 
          "format": "strict_date_optional_time||epoch_millis"

In the mapping you can define the field, and each field as a datatype. Read the official guide for all datatypes.
Principles datatype:
– boolean
– int | short | long
– date
– text
– keyword
– specialized type (as IP, Completion (autocomplete), Token count datatype)


NEST is a high level client that has the advantage of having mapped all the request and response objects, comes with a strongly typed query DSL that maps 1 to 1 with the Elasticsearch query DSL, and takes advantage of specific .NET features such as covariant results and auto mapping of POCOs. NEST internally uses and still exposes the low level Elasticsearch.Net client.
Link to download NEST.


#Connect to elastic search server
ElasticClient client = new ElasticClient(new Uri("http://localhost:9200"));

Now we must to create the filter query to take data.
Using Nest to take this is very simple, i show you an example:

#Create our query container
QueryContainer filters = null;
#take a filter on datetime
var filterDate = new QueryContainerDescriptor<Record>().DateRange(t => t.Field("datetimeborn")
#Add the filter on query container
filters &= (filterDate);
#You can use the Or
filters |= (filterDate);

Mapping of data type and method:
Boolean => Exists
Date => DateRange
Number => Range
Text Like => WildCard
Text Exact => Term

#Elastic Search Query
POST students/_search
      "path": "information", 

#Nest c# query
var filterWildCard = new QueryContainerDescriptor<Record>().WildCard(t => t.Field("").Value("*SURNAME*"));

Now i’have used the Bool Query type, but exist other type, remind you to this official link.

#Execute client search
var response = client.Search<IndexType>(s => s
	.Query(q => q.Bool(bq => bq.Filter(filters))

#In the response we find
var documents = response.Documents;


The scroll API allows you to efficiently page through a large dataset as it keeps the query alive in the cluster. And if you want all / unlimited data, without pagination.