user4042832
user4042832

Reputation:

Elastic Search Query

I'm working on a LDAP server. There is Elastic search on it. I must send the query with some Javascript's code (in JSON format).

This is my query:

curl -xget wwww....
{
  "query": {
    "filtered": {
      "query": {
        "match_all": {}
      },
      "filter": {
        "term": {
          "server": "serveur_name404"
        }
      }
    }
  }
}

I'm trying to print all the result where "server" = "server_name" (ths field is server:server_name..). Docs about Elastic search is too much small, I though. I've find some documentation but it's the same, no help for new user.. The example is too much simplistic.

This query return me all results, with any filter.

Ps: It's like in mysql "Where server = 'server_name404'"

Upvotes: 0

Views: 189

Answers (2)

P-DOX
P-DOX

Reputation: 383

curl -XPOST <cluster address>/<index name>
{
    "query": {
        "match": {
            "server.keyword": "serveur_name404"
        }
    }
}

Upvotes: 0

bittusarkar
bittusarkar

Reputation: 6357

If you want to get all fields of an Elasticsearch document whose server field has the value serveur_name404 you can achieve that by a very simple query.

curl -XPOST <cluster address>/<index name>
{
    "query": {
        "term": {
            "server": "serveur_name404"
        }
    }
}

Upvotes: 0

Related Questions