Query: python elasticsearch list of types in index

Relevant code:
def determine_types(self):
        """ Determine ES type names from request data.

        In particular `request.matchdict['collections']` is used to
        determine types names. Its value is comma-separated sequence
        of collection names under which views have been registered.
        """
        from nefertari.elasticsearch import ES
        collections = self.get_collections()
        resources = self.get_resources(collections)
        models = set([res.view.Model for res in resources])
        es_models = [mdl for mdl in models if mdl
                     and getattr(mdl, '_index_enabled', False)]
        types = [ES.src2type(mdl.__name__) for mdl in es_models]
        return types

Similar but not relevant code:
def can_elasticsearch(record):
    """Check if a given record is indexed.

    :param record: A record object.
    :returns: If the record is indexed returns `True`, otherwise `False`.
    """
    search = request._methodview.search_class()
    search = search.get_record(str(record.id))
    return search.count() == 1

Similar but not relevant code:
def index(obj, index=INDEX_NAME, doc_type=DOC_TYPE):
    """
    Index the given document.

    https://elasticsearch-py.readthedocs.io/en/master/api.html#elasticsearch.Elasticsearch.index
    https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html
    """
    doc = to_dict(obj)

    if doc is None:
        return

    id = doc.pop('id')

    return es_conn.index(index, doc_type, doc, id=id)

Similar but not relevant code:
def all_documents(index=INDEX_NAME):
    """
    Get all documents from the given index.

    Returns full Elasticsearch objects so you can get metadata too.
    """
    query = {
        'query': {
            'match_all': {}
        }
    }
    for result in raw_query(query, index=index):
        yield result

Similar but not relevant code:
def get_record_by_name(self, index, name):
        """
        Searches for a single document in the given index on the 'name' field .
        Performs a case-insensitive search by utilizing Elasticsearch's `match_phrase` query.
    
        Args:
            index: `str`. The name of an Elasticsearch index (i.e. biosamples).
            name: `str`. The value of a document's name key to search for.
    
        Returns:
            `dict` containing the document that was indexed into Elasticsearch.
    
        Raises:
            `MultipleHitsException`: More than 1 hit is returned.
        """
        result = self.ES.search(
            index=index,
            body={
                "query": {
                    "match_phrase": {
                        "name": name,
                    }
                }
            }
        )
        hits = result["hits"]["hits"]
        if not hits:
            return {}
        elif len(hits) == 1:
            return hits[0]["_source"]
        else:
            # Mult. records found with same prefix. See if a single record whose name attr matches
            # the match phrase exactly (in a lower-case comparison).  
            for h in hits:
                source = h["_source"]
                record_name = source["name"]
                if record_name.lower().strip() == name.lower().strip():
                    return source
            msg = "match_phrase search found multiple records matching query '{}' for index '{}'.".format(name, index)
            raise MultipleHitsException(msg)

Similar but not relevant code:
def bulk_load_docs(es, docs):
    """Bulk load docs

    Args:
        es: elasticsearch handle
        docs: Iterator of doc objects - includes index_name
    """

    chunk_size = 200

    try:
        results = elasticsearch.helpers.bulk(es, docs, chunk_size=chunk_size)
        log.debug(f"Elasticsearch documents loaded: {results[0]}")

        # elasticsearch.helpers.parallel_bulk(es, terms, chunk_size=chunk_size, thread_count=4)
        if len(results[1]) > 0:
            log.error("Bulk load errors {}".format(results))
    except elasticsearch.ElasticsearchException as e:
        log.error("Indexing error: {}\n".format(e))