Exemplo n.º 1
0
def test_es_async_1():
    client = connections.get_es_client('localhost:9200', True)
    health = ESHealth(client)

    async def main():
        response = await health.async_check()
        print(vars(response))

    asyncio.run(main())
Exemplo n.º 2
0
def test_es():
    client = connections.get_es_client("localhost:9200")
    indices = {None: "bts_test", "gene": "bts_test"}

    metadata = BiothingsESMetadata(indices, client)
    metadata.refresh()

    print(metadata.biothing_metadata)
    print(metadata.biothing_mappings)
    print(metadata.biothing_licenses)
Exemplo n.º 3
0
def test_es():
    client = connections.get_es_client("localhost:9200", True)
    pipeline = ESQueryPipeline(ESQueryBuilder(), ESQueryBackend(client),
                               ESResultFormatter())
    # print(pipeline.fetch("ecf3767159a74988", rawquery=1))
    print(pipeline.fetch("ecf3767159a74988", _source=['_*']))
    print(pipeline.fetch("nonexists"))
    print(pipeline.search("infection", scopes=["name"], _source=['_*',
                                                                 'name']))
    print(pipeline.search("nonexists", scopes=["name"]))
Exemplo n.º 4
0
def test_es_async_3():
    client = connections.get_es_client('localhost:9200', True)
    health = ESHealth(client, {
        'index': 'nonexists',
        'id': "1017",
    })

    async def main():
        response = await health.async_check()
        print(vars(response))

    asyncio.run(main())
Exemplo n.º 5
0
def test_es_async_2():
    client = connections.get_es_client('localhost:9200', True)
    health = ESHealth(client, {
        'index': 'bts_test',
        'id': "1017",
        '_source': ['taxid', 'symbol']
    })

    async def main():
        response = await health.async_check()
        print(vars(response))

    asyncio.run(main())
Exemplo n.º 6
0
    def __init__(self,
                 builder=None,
                 backend=None,
                 formatter=None,
                 *args,
                 **kwargs):
        if not builder:
            from biothings.web.query.builder import ESQueryBuilder
            builder = ESQueryBuilder()

        if not backend:
            from biothings.web.connections import get_es_client
            from biothings.web.query.engine import ESQueryBackend
            client = get_es_client(async_=True)
            backend = ESQueryBackend(client)

        if not formatter:
            from biothings.web.query.formatter import ESResultFormatter
            formatter = ESResultFormatter()

        super().__init__(builder, backend, formatter, *args, **kwargs)