@classmethod
def analyze(cls, data, analyzer, return_as_tokens=False):
    """Make an analyze request.

    data: string to be analyzed.
    analyzer: str name of the analyzer we'll use.
    return_as_tokens: bool, flags for return type list or string.

    return: ElasticSearch result if return_as_tokens not set, else return list.

    """
    conn = cls.get_connection()
    if isinstance(data, str):
        data = {'text': data}
    data['analyzer'] = analyzer
    analyze_model = cls.get_analyse_model()
    if analyze_model:
        index_name = analyze_model.get_index_name()
    else:
        index_name = cls.get_index_name()
    result = conn.indices.analyze(index=index_name, body=data)
    value = []
    for token in result.get('tokens', []):
        value.append(token['token'])
    if return_as_tokens:
        return value
    return ' '.join(value)
