"ngram highlighting":
  - do:
      indices.create:
        index: test
        body:
          settings:
            number_of_shards: 1
            number_of_replicas: 0
            index.max_ngram_diff: 19
            analysis:
              tokenizer:
                my_ngramt:
                  type: ngram
                  min_gram: 1
                  max_gram: 20
                  token_chars: letter,digit
              filter:
                my_ngram:
                  type: ngram
                  min_gram: 1
                  max_gram: 20
              analyzer:
                name2_index_analyzer:
                  tokenizer: whitespace
                  filter: [my_ngram]
                name_index_analyzer:
                  tokenizer: my_ngramt
                name_search_analyzer:
                  tokenizer: whitespace
          mappings:
            properties:
              name:
                type: text
                term_vector: with_positions_offsets
                analyzer: name_index_analyzer
                search_analyzer: name_search_analyzer
              name2:
                type: text
                term_vector: with_positions_offsets
                analyzer: name2_index_analyzer
                search_analyzer: name_search_analyzer

  - do:
      index:
        index: test
        id:    "1"
        refresh: true
        body:
          name: logicacmg ehemals avinci - the know how company
          name2: logicacmg ehemals avinci - the know how company

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          query:
            match:
              name:
                query: logica m
          highlight:
            fields:
              - name: {}
  - match: {hits.total: 1}
  - match: {hits.hits.0.highlight.name.0: "<em>logica</em>c<em>m</em>g ehe<em>m</em>als avinci - the know how co<em>m</em>pany"}

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          query:
            match:
              name:
                query: logica ma
          highlight:
            fields:
              - name: {}
  - match: {hits.total: 1}
  - match: {hits.hits.0.highlight.name.0: "<em>logica</em>cmg ehe<em>ma</em>ls avinci - the know how company"}

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          query:
            match:
              name:
                query: logica
          highlight:
            fields:
              - name: {}
  - match: {hits.total: 1}
  - match: {hits.hits.0.highlight.name.0: "<em>logica</em>cmg ehemals avinci - the know how company"}

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          query:
            match:
              name2:
                query: logica m
          highlight:
            fields:
              - name2: {}
  - match: {hits.total: 1}
  - match: {hits.hits.0.highlight.name2.0: "<em>logicacmg</em> <em>ehemals</em> avinci - the know how <em>company</em>"}

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          query:
            match:
              name2:
                query: logica ma
          highlight:
            fields:
              - name2: {}
  - match: {hits.total: 1}
  - match: {hits.hits.0.highlight.name2.0: "<em>logicacmg</em> <em>ehemals</em> avinci - the know how company"}

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          query:
            match:
              name2:
                query: logica
          highlight:
            fields:
              - name2: {}
  - match: {hits.total: 1}
  - match: {hits.hits.0.highlight.name2.0: "<em>logicacmg</em> ehemals avinci - the know how company"}
