title: re-indexing problem with suggesters from elastic v1.7 to elastic 7.X problem
body: <p>I have problem with the reindex, I‘m not sure 100% that the solution I found is the best as we are having issues to work with the index from the java client. So I want to confirm if the re-indexing steps are correct:</p>
  <p>Problem Description:
  I have an index on an old v1.7 that need to migrate to elasticsearch v7.x that uses context suggesters.</p>
  <pre><code>GET /autocompleteterms_v20/_search?pretty 
  {
   &quot;took&quot; : 2,
   &quot;timed_out&quot; : false,
   &quot;_shards&quot; : {
   &quot;total&quot; : 1,
   &quot;successful&quot; : 1,
   &quot;failed&quot; : 0
  },
   &quot;hits&quot; : {
   &quot;total&quot; : 4130,
   &quot;max_score&quot; : 1.0,
   &quot;hits&quot; : [ {
   &quot;_index&quot; : &quot;autocompleteterms_v20&quot;,
   &quot;_type&quot; : &quot;autoitem&quot;,
   &quot;_id&quot; : &quot;en_incorporated_by_reference&quot;,
   &quot;_score&quot; : 1.0,
   &quot;_source&quot;:{ &quot;name&quot;: &quot;incorporated by reference&quot;, &quot;name_suggest&quot;: { &quot;input&quot;: &quot;incorporated by reference&quot;, &quot;context&quot;: { &quot;lang&quot;: &quot;en&quot; }, &quot;weight&quot;: 393 } }
   }, {
   &quot;_index&quot; : &quot;autocompleteterms_v20&quot;,
   &quot;_type&quot; : &quot;autoitem&quot;,
   &quot;_id&quot; : &quot;en_double_gaming&quot;,
   &quot;_score&quot; : 1.0,
   &quot;_source&quot;:{ &quot;name&quot;: &quot;double gaming&quot;, &quot;name_suggest&quot;: { &quot;input&quot;: &quot;double gaming&quot;, &quot;context&quot;: { 
   &quot;lang&quot;: &quot;en&quot; }, &quot;weight&quot;: 371 } }
   }, {
   &quot;_index&quot; : &quot;autocompleteterms_v20&quot;,
  &quot;_type&quot; : &quot;autoitem&quot;,
  &quot;_id&quot; : &quot;en_checking_for_players&quot;,
  &quot;_score&quot; : 1.0,
  &quot;_source&quot;:{ &quot;name&quot;: &quot;checking for players&quot;, &quot;name_suggest&quot;: { &quot;input&quot;: &quot;checking for players&quot;, 
   &quot;context&quot;: { &quot;lang&quot;: &quot;en&quot; }, &quot;weight&quot;: 2 } }
  },
  </code></pre>
  <hr />
  <pre><code>GET /autocompleteterms_v20/_mapping?pretty
  {
  &quot;autocompleteterms_v20&quot; : {
  &quot;mappings&quot; : {
  &quot;autoitem&quot; : {
  &quot;properties&quot; : {
  &quot;name&quot; : {
  &quot;type&quot; : &quot;string&quot;
  },
  &quot;name_suggest&quot; : {
  &quot;type&quot; : &quot;completion&quot;,
  &quot;analyzer&quot; : &quot;standard&quot;,
  &quot;payloads&quot; : true,
  &quot;preserve_separators&quot; : false,
  &quot;preserve_position_increments&quot; : false,
  &quot;max_input_length&quot; : 50,
   &quot;context&quot; : {
   &quot;lang&quot; : {
   &quot;type&quot; : &quot;category&quot;,
   &quot;path&quot; : &quot;lang_field&quot;,
   &quot;default&quot; : [ &quot;en&quot; ]
    }
   }
   }
   }
   }
   }
   }
   }
  </code></pre>
  <p>To reindex to the new cluster I have found that there were some breaking changes in v5 for the suggesters so when tried to transform the fields of the index on the reindex</p>
  <ol>
  <li><p>First I create the mapping:</p>
  <pre><code>PUT autocompleteterms_v20 {
   &quot;settings&quot;: {
   &quot;index&quot;: {
   &quot;number_of_shards&quot;: 2,
   &quot;number_of_replicas&quot;: 0
   }
  },
  &quot;mappings&quot;: {
   &quot;properties&quot;: {
   &quot;name&quot;: {
    &quot;type&quot;: &quot;text&quot;
  },
   &quot;name_suggest&quot;: {
  &quot;type&quot;: &quot;completion&quot;,
  &quot;analyzer&quot;: &quot;standard&quot;,
  &quot;preserve_separators&quot;: false,
  &quot;preserve_position_increments&quot;: false,
  &quot;max_input_length&quot;: 50,
  &quot;contexts&quot;: [
  {
   &quot;name&quot;: &quot;lang&quot;,
   &quot;type&quot;: &quot;category&quot;,
   &quot;path&quot;: &quot;lang_field&quot;
    }
  ]
  }
  }
  }
  }
  {
   &quot;acknowledged&quot; : true,
   &quot;shards_acknowledged&quot; : true,
   &quot;index&quot; : &quot;autocompleteterms_v20&quot;
  }
  </code></pre>
  </li>
  <li><p>After that I reindex changing the field context to contexts:</p>
  <pre><code> POST _reindex {
   &quot;source&quot;: {
   &quot;remote&quot;: {
    &quot;host&quot;: http://x.x.x.x:9200,
    &quot;username&quot;: &quot;user&quot;,
    &quot;password&quot;: &quot;password&quot;
   },
   &quot;index&quot;: &quot;autocompleteterms_v20&quot;
   },
   &quot;dest&quot;: {
   &quot;index&quot;: &quot;autocompleteterms_v20&quot;
  },
  &quot;script&quot;: {
  &quot;source&quot;: &quot;&quot;&quot; 
  ctx._source.name_suggest.contexts = ctx._source.name_suggest.context;
  ctx._source['name_suggest'].remove('context');
  &quot;&quot;&quot;,
  &quot;lang&quot;: &quot;painless&quot;
  }
  }
  {
  &quot;took&quot; : 366,
  &quot;timed_out&quot; : false,
  &quot;total&quot; : 4130,
  &quot;updated&quot; : 0,
  &quot;created&quot; : 4130,
  &quot;deleted&quot; : 0,
  &quot;batches&quot; : 5,
  &quot;version_conflicts&quot; : 0,
  &quot;noops&quot; : 0,
  &quot;retries&quot; : {
  &quot;bulk&quot; : 0,
  &quot;search&quot; : 0
  },
  &quot;throttled_millis&quot; : 0,
  &quot;requests_per_second&quot; : -1.0,
  &quot;throttled_until_millis&quot; : 0,
  &quot;failures&quot; : [ ]
  }
  </code></pre>
  </li>
  <li><p>When I make a query using explicit context I get results:</p>
  <pre><code> POST /autocompleteterms_v20/_search {
   &quot;suggest&quot;: {
   &quot;text&quot;: &quot;spirit&quot;,
   &quot;completion&quot;: {
   &quot;field&quot;: &quot;name_suggest&quot;,
   &quot;contexts&quot;: {
   &quot;lang&quot;: [ 
      { &quot;context&quot;: &quot;en&quot; }
     ]
     }
    }
    }
    }
    }
    {
    &quot;took&quot; : 5,
    &quot;timed_out&quot; : false,
    &quot;_shards&quot; : {
    &quot;total&quot; : 2,
    &quot;successful&quot; : 2,
    &quot;skipped&quot; : 0,
    &quot;failed&quot; : 0
    },
    &quot;hits&quot; : {
    &quot;total&quot; : {
    &quot;value&quot; : 0,
    &quot;relation&quot; : &quot;eq&quot;
    },
    &quot;max_score&quot; : null,
    &quot;hits&quot; : [ ]
    },
    &quot;suggest&quot; : {
    &quot;completeMe&quot; : [
    {
    &quot;text&quot; : &quot;spirit&quot;,
    &quot;offset&quot; : 0,
    &quot;length&quot; : 6,
    &quot;options&quot; : [
    {
     &quot;text&quot; : &quot;spirit&quot;,
     &quot;_index&quot; : &quot;autocompleteterms_v20&quot;,
     &quot;_type&quot; : &quot;_doc&quot;,
     &quot;_id&quot; : &quot;en_spirit&quot;,
     &quot;_score&quot; : 290.0,
     &quot;_source&quot; : {
     &quot;name_suggest&quot; : {
     &quot;input&quot; : &quot;spirit&quot;,
     &quot;weight&quot; : 290,
     &quot;contexts&quot; : {
     &quot;lang&quot; : &quot;en&quot;
      }
     },
     &quot;name&quot; : &quot;spirit&quot;
     },
     &quot;contexts&quot; : {
     &quot;lang&quot; : [
     &quot;en&quot;
    ]
    }
    },
    {
   &quot;text&quot; : &quot;spirit of the game&quot;,
   &quot;_index&quot; : &quot;autocompleteterms_v20&quot;,
   &quot;_type&quot; : &quot;_doc&quot;,
   &quot;_id&quot; : &quot;en_spirit_of_the_game&quot;,
   &quot;_score&quot; : 34.0,
   &quot;_source&quot; : {
   &quot;name_suggest&quot; : {
    &quot;input&quot; : &quot;spirit of the game&quot;,
   &quot;weight&quot; : 34,
   &quot;contexts&quot; : {
   &quot;lang&quot; : &quot;en&quot;
   }
  },
  &quot;name&quot; : &quot;spirit of the game&quot;
   },
  &quot;contexts&quot; : {
   &quot;lang&quot; : [
      &quot;en&quot;
     ]
     }
   }
  </code></pre>
  </li>
  <li><p>But when I make a query without context I get an error:</p>
  <pre><code> POST /autocompleteterms_v20/_search
   {
   &quot;suggest&quot;: {
    &quot;completeMe&quot;: {
    &quot;text&quot;: &quot;spirit&quot;,
    &quot;completion&quot;: {
    &quot;field&quot;: &quot;name_suggest&quot;
    }
   }
  }
  }
   {
    &quot;error&quot; : {
     &quot;root_cause&quot; : [
    {
     &quot;type&quot; : &quot;illegal_argument_exception&quot;,
     &quot;reason&quot; : &quot;Missing mandatory contexts in context query&quot;
    }
    ],
    &quot;type&quot; : &quot;search_phase_execution_exception&quot;,
   &quot;reason&quot; : &quot;all shards failed&quot;,
   &quot;phase&quot; : &quot;query&quot;,
   &quot;grouped&quot; : true,
   &quot;failed_shards&quot; : [
   {
   &quot;shard&quot; : 0,
   &quot;index&quot; : &quot;autocompleteterms_v20&quot;,
   &quot;node&quot; : &quot;B7EpKWRVRzGkLCnl7CZapQ&quot;,
   &quot;reason&quot; : {
   &quot;type&quot; : &quot;illegal_argument_exception&quot;,
   &quot;reason&quot; : &quot;Missing mandatory contexts in context query&quot;
   }
   }
    ],
   &quot;caused_by&quot; : {
  &quot;type&quot; : &quot;illegal_argument_exception&quot;,
  &quot;reason&quot; : &quot;Missing mandatory contexts in context query&quot;,
  &quot;caused_by&quot; : {
  &quot;type&quot; : &quot;illegal_argument_exception&quot;,
  &quot;reason&quot; : &quot;Missing mandatory contexts in context query&quot;
   }
   }
    },
    &quot;status&quot; : 400
  }
  </code></pre>
  </li>
  </ol>
  <p>But in the breaking change from v5.0 we have <a href="https://www.elastic.co/guide/en/elasticsearch/reference/5.0/breaking_50_suggester.html#_completion_mapping_with_multiple_contexts" rel="nofollow noreferrer">https://www.elastic.co/guide/en/elasticsearch/reference/5.0/breaking_50_suggester.html#_completion_mapping_with_multiple_contexts</a></p>
  <p>it is mentioned:
  &quot;New queries with no context against a context-enabled completion field yields results from all indexed suggestions&quot;</p>
  <p><strong>In this context I have two main questions:</strong></p>
  <ol>
  <li>Is the reindexing of the old index is done correctly?</li>
  <li>How can I do queries without choosing context against that index?</li>
  </ol>