---
"Default index":

  - skip:
      version: " - 5.99.99"
      reason:  this uses a new feature that has been added in 6.0.0

  - do:
      indices.create:
          index:  goodbad
          body:
            settings:
                number_of_shards: "1"
            mappings:
                doc:
                    properties:
                        text:
                            type: text
                            fielddata: false
                        class:
                            type: keyword

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



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

  - do:
      search:
        index: goodbad
        type:  doc

  - match: {hits.total: 7}
  
  - do:
      search:
        index: goodbad
        type:  doc
        body: {"aggs": {"class": {"terms": {"field": "class"},"aggs": {"sig_text": {"significant_text": {"field": "text"}}}}}}

  - match: {aggregations.class.buckets.0.sig_text.buckets.0.key: "bad"}
  - match: {aggregations.class.buckets.1.sig_text.buckets.0.key: "good"}
  
---
"Dedup noise":

  - skip:
      version: " - 5.99.99"
      reason:  this uses a new feature that has been added in 6.0.0

  - do:
      indices.create:
          index:  goodbad
          body:
            settings:
                number_of_shards: "1"
            mappings:
                doc:
                    properties:
                        text:
                            type: text
                            fielddata: false
                        class:
                            type: keyword

  - do:
      index:
          index:  goodbad
          type:   doc
          id:     1
          body:   { text: "good noisewords1 g1 g2 g3 g4 g5 g6", class: "good" }
  - do:
      index:
          index:  goodbad
          type:   doc
          id:     2
          body:   { text: "good  noisewords2 g1 g2 g3 g4 g5 g6", class: "good" }
  - do:
      index:
          index:  goodbad
          type:   doc
          id:     3
          body:   { text: "bad noisewords3 b1 b2 b3 b4 b5 b6", class: "bad" }
  - do:
      index:
          index:  goodbad
          type:   doc
          id:     4
          body:   { text: "bad noisewords4 b1 b2 b3 b4 b5 b6", class: "bad" }
  - do:
      index:
          index:  goodbad
          type:   doc
          id:     5
          body:   { text: "good bad noisewords5 gb1 gb2 gb3 gb4 gb5 gb6", class: "good" }
  - do:
      index:
          index:  goodbad
          type:   doc
          id:     6
          body:   { text: "good bad noisewords6 gb1 gb2 gb3 gb4 gb5 gb6", class: "bad" }
  - do:
      index:
          index:  goodbad
          type:   doc
          id:     7
          body:   { text: "bad noisewords7 b1 b2 b3 b4 b5 b6", class: "bad" }



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

  - do:
      search:
        index: goodbad
        type:  doc

  - match: {hits.total: 7}
  
  - do:
      search:
        index: goodbad
        type:  doc
        body: {"aggs": {"class": {"terms": {"field": "class"},"aggs": {"sig_text": {"significant_text": {"field": "text", "filter_duplicate_text": true}}}}}}

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