code: def get(self, **kwargs):
          
          completions = []
          size = request.values.get('size', type=int)
  
          for k in self.suggesters.keys():
              val = request.values.get(k)
              if val:
                  # Get completion suggestions
                  opts = copy.deepcopy(self.suggesters[k])
  
                  if 'context' in opts.get('completion', {}):
                      ctx_field = opts['completion']['context']
                      ctx_val = request.values.get(ctx_field)
                      if not ctx_val:
                          raise SuggestMissingContextRESTError
                      opts['completion']['context'] = {
                          ctx_field: ctx_val
                      }
  
                  if size:
                      opts['completion']['size'] = size
  
                  completions.append((k, val, opts))
  
          if not completions:
              raise SuggestNoCompletionsRESTError(
                  ', '.join(sorted(self.suggesters.keys())))
  
          # Add completions
          s = self.search_class()
          for field, val, opts in completions:
              source = opts.pop('_source', None)
              if source is not None and ES_VERSION[0] >= 5:
                  s = s.source(source).suggest(field, val, **opts)
              else:
                  s = s.suggest(field, val, **opts)
  
          if ES_VERSION[0] == 2:
              # Execute search
              response = s.execute_suggest().to_dict()
              for field, _, _ in completions:
                  for resp in response[field]:
                      for op in resp['options']:
                          if 'payload' in op:
                              op['_source'] = copy.deepcopy(op['payload'])
          elif ES_VERSION[0] >= 5:
              response = s.execute().to_dict()['suggest']
  
          result = dict()
          for field, val, opts in completions:
              result[field] = response[field]
  
          return make_response(jsonify(result))
docs: Get suggestions.