olivere / elastic

Deprecated: Use the official Elasticsearch client for Go at https://github.com/elastic/go-elasticsearch
https://olivere.github.io/elastic/
MIT License
7.42k stars 1.15k forks source link

how to express `GET alias_xxx/_alias?filter_path=index_name.aliases.alias_xxx` #1632

Closed RaphaelL2e closed 2 years ago

RaphaelL2e commented 2 years ago

Please use the following questions as a guideline to help me answer your issue/question without further inquiry. Thank you.

Which version of Elastic are you using?

[x ] elastic.v7 (for Elasticsearch 7.x) [ ] elastic.v6 (for Elasticsearch 6.x) [ ] elastic.v5 (for Elasticsearch 5.x) [ ] elastic.v3 (for Elasticsearch 2.x) [ ] elastic.v2 (for Elasticsearch 1.x)

Please describe the expected behavior

GET alias_xxx/_alias?filter_path=index_name.aliases.alias_xxx

but may cant use olivere implement

Please describe the actual behavior

i want result this filter

{
  "indedx_name" : {
    "aliases" : {
      "alias_name" : {
        "filter" : {
          "bool" : {
            "filter" : [
              {

              }
            ]
          }
        }
      }
    }
  }
}

Any steps to reproduce the behavior?

olivere commented 2 years ago

The API you need is IndicesGetAliases. Here's a lot of code on how to work with that API. The FilterPath method is on the service here.

HTH.

RaphaelL2e commented 2 years ago

but i think IndicesGetAliases only return

indexMap := make(map[string]struct {
        Aliases map[string]struct {
            IsWriteIndex bool `json:"is_write_index"`
        } `json:"aliases"`
    })

dont have my want filter body

olivere commented 2 years ago

That's what IndicesGetAliases returns IIRC. What API is that GET alias_xxx/_alias endpoint? Can you refer me to the documentation page on elastic.co?

RaphaelL2e commented 2 years ago

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-get-alias.html

olivere commented 2 years ago

So the API is correct (the indices_get_aliases.go implements the endpoint you want). But you're missing part of the response?

RaphaelL2e commented 2 years ago

yes

olivere commented 2 years ago

Unfortunately, as the response is dynamic, all you can do is to use e.g. the PerformRequest method on the Client then and parse the body on your side.

RaphaelL2e commented 2 years ago

ok,thx