Fastapi: [FEATURE]: additional backends (including elasticsearch) as full-stack implementations

Created on 6 May 2019  路  4Comments  路  Source: tiangolo/fastapi

Is your feature request related to a problem? Please describe.
Elasticsearch is a common backend for APIs. The full-stack solutions for Postgres and Couchbase are fantastic and include a lot of the tedious details for running FastAPI in production. It would be nice to have an Elasticsearch-based full-stack for FastAPI.

Describe the solution you'd like

  • Elasticsearch configuration (no need to include elasticsearch as part of the solution)
  • The rest of the full-stack

Describe alternatives you've considered
An alternative is to start with the postgres or couchbase full-stacks and add elasticsearch. That seems like a viable option, but such a solution would then include some potentially unnecessary components.

Another interesting alternative is to strip down the full-stack to include everything needed to run, but leave the backend out and leave that to the user.

Additional context
This is not a high-priority item from my own perspective. I wanted to register the thought here.

enhancement

Most helpful comment

+1 for elasticsearch integration, +1 for not using it as a primary backing store

Here's a gist showing the delta I made relative to the postgres-fastapi project to get elasticsearch 7 to be part of the docker-compose set-up, and shows how to create the Elasticsearch client instance for use with elasticsearch-py (optionally async) and/or elasticsearch-dsl: https://gist.github.com/dmontagu/f7bb7db40e63f5bc6304ceba54604c89

All 4 comments

Thanks! I have used ElasticSearch as the main backend before, but as they seem to pitch heavily that it's not to be used as the main data storage system, I always get doubts about it.

They normally suggest adding it as a complement to another data storage system, like PostgreSQL or MongoDB. So, I guess starting with PostgreSQL and extending it would be viable.

On the other side, Couchbase includes a full-text search engine. And it takes care of synchronizing/indexing the documents in the main data storage system and the full-text search engine. So, that might be worth checking. The full-stack generator with Couchbase includes indexes, crud utils for search, and docs. That might be a viable solution for now.

All good points, @tiangolo. Just for completeness, PostgreSQL has great full text capabilities as well. In addition, I recently tried out a postgresql extension, zombodb, that adds elasticsearch index maintenance and query capabilities directly to postgresql. In some basic testing, it seems to work as expected and offers a SQL-centric approach to elasticsearch with all the niceties of postgresql.

Thanks for sharing it, looks very interesting. I see it doesn't support ES 7 yet, but it seems they will support it soon (by your own issue there).

I'll have it in mind to check it and see how could we integrate it without making it required.

+1 for elasticsearch integration, +1 for not using it as a primary backing store

Here's a gist showing the delta I made relative to the postgres-fastapi project to get elasticsearch 7 to be part of the docker-compose set-up, and shows how to create the Elasticsearch client instance for use with elasticsearch-py (optionally async) and/or elasticsearch-dsl: https://gist.github.com/dmontagu/f7bb7db40e63f5bc6304ceba54604c89

Was this page helpful?
0 / 5 - 0 ratings