olivere / elastic

Deprecated: Use the official Elasticsearch client for Go at https://github.com/elastic/go-elasticsearch

Home Page:https://olivere.github.io/elastic/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

have problem to use elastic package

khalil-farashiani opened this issue · comments

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?

[ ] elastic.v7 (for Elasticsearch 7.x)

Please describe the expected behavior

hey, I have a JSON query for elastic but I can't cover to elastic/v7 Golang package
the query is:

{
  "size": 0,
  "_source": false,
  "aggregations": {
    "groupby": {
      "composite": {
        "size": 1000,
        "sources": [
          {
            "cocode": {
              "terms": {
                "field": "f1",
                "missing_bucket": true,
                "order": "asc"
              }
            }
          },
          {
            "issuccess": {
              "terms": {
                "field": "f2",
                "missing_bucket": true,
                "order": "asc"
              }
            }
          },
          {
            "method": {
              "terms": {
                "field": "method.keyword",
                "missing_bucket": true,
                "order": "asc"
              }
            }
          }
        ]
      }
    }
  },
  "query": {
    "bool": {
      "must": [
        {
          "range": {
            "endtime": {
              "gt": "now-10m"
            }
          }
        }
      ]
    }
  }
}

should I use NewCompositeAggregationTermsValuesSource() func?
isn't there a method just putting raw string query? something like execute raw SQL query with ORMs

There is SearchService.Source

Source allows the user to set the request body manually without using any of the structs and interfaces in Elastic.

Oh, Thanks a lot.

Feel free to look into the test files. In search_test.go you will find dozens of examples of various techniques. Also, there is RawStringQuery, or you can use PerformRequest if you want the lowest level of access.