All Downloads are FREE. Search and download functionalities are using the official Maven repository.

rest-api-spec.test.search.aggregation.30_sig_terms.yml Maven / Gradle / Ivy

The newest version!
---
"Default index":
  - do:
      indices.create:
          index:  goodbad
          body:
            settings:
                number_of_shards: "1"
            mappings:
                properties:
                    text:
                        type: text
                        fielddata: true
                    class:
                        type: keyword

  - do:
      index:
          index:  goodbad
          id:     1
          body:   { text: "good", class: "good" }
  - do:
      index:
          index:  goodbad
          id:     2
          body:   { text: "good", class: "good" }
  - do:
      index:
          index:  goodbad
          id:     3
          body:   { text: "bad", class: "bad" }
  - do:
      index:
          index:  goodbad
          id:     4
          body:   { text: "bad", class: "bad" }
  - do:
      index:
          index:  goodbad
          id:     5
          body:   { text: "good bad", class: "good" }
  - do:
      index:
          index:  goodbad
          id:     6
          body:   { text: "good bad", class: "bad" }
  - do:
      index:
          index:  goodbad
          id:     7
          body:   { text: "bad", class: "bad" }



  - do:
      indices.refresh:
        index: [goodbad]

  - do:
      search:
        rest_total_hits_as_int: true
        index: goodbad

  - match: {hits.total: 7}

  - do:
      search:
        rest_total_hits_as_int: true
        index: goodbad
        body: {"aggs": {"class": {"terms": {"field": "class"},"aggs": {"sig_terms": {"significant_terms": {"field": "text"}}}}}}

  - match: {aggregations.class.buckets.0.sig_terms.buckets.0.key: "bad"}
  - match: {aggregations.class.buckets.1.sig_terms.buckets.0.key: "good"}

---
"IP test":
  - do:
      indices.create:
          index:  ip_index
          body:
            mappings:
                properties:
                    ip:
                        type: ip

  - do:
      index:
          index:  ip_index
          id:     1
          body:   { ip: "::1" }
  - do:
      index:
          index:  ip_index
          id:     2
          body:   { }

  - do:
      indices.refresh: {}

  - do:
      search:
        rest_total_hits_as_int: true
        body: { "query" : { "exists" : { "field" : "ip" } }, "aggs" : { "ip_terms" : { "significant_terms" : { "field" : "ip", "min_doc_count" : 1 } } } }

  - match: { hits.total: 1 }

  - length: { aggregations.ip_terms.buckets: 1 }

  - match: { aggregations.ip_terms.buckets.0.key: "::1" }

  - is_false: aggregations.ip_terms.buckets.0.key_as_string

  - match: { aggregations.ip_terms.buckets.0.doc_count: 1 }

  - do:
      search:
        rest_total_hits_as_int: true
        body: { "query" : { "exists" : { "field" : "ip" } }, "aggs" : { "ip_terms" : { "significant_terms" : { "field" : "ip", "min_doc_count" : 1, "include" : [ "::1" ] } } } }

  - match: { hits.total: 1 }

  - length: { aggregations.ip_terms.buckets: 1 }

  - match: { aggregations.ip_terms.buckets.0.key: "::1" }

  - do:
      search:
        rest_total_hits_as_int: true
        body: { "query" : { "exists" : { "field" : "ip" } }, "aggs" : { "ip_terms" : { "significant_terms" : { "field" : "ip", "min_doc_count" : 1, "exclude" : [ "::1" ] } } } }

  - match: { hits.total: 1 }

  - length: { aggregations.ip_terms.buckets: 0 }

  - do:
      catch: /Aggregation \[ip_terms\] cannot support regular expression style include\/exclude settings as they can only be applied to string fields\. Use an array of values for include\/exclude clauses/
      search:
        rest_total_hits_as_int: true
        body: { "size" : 0, "aggs" : { "ip_terms" : { "significant_terms" : { "field" : "ip", "exclude" :  "127.*"  } } } }

---
'Misspelled fields get "did you mean"':
  - skip:
      version: " - 7.6.99"
      reason: Implemented in 8.0 (to be backported to 7.7)
  - do:
      catch: /\[significant_terms\] unknown field \[jlp\] did you mean \[jlh\]\?/
      search:
          body:
            aggs:
              foo:
                significant_terms:
                  field: foo
                  jlp: {}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy