A simple application for searching any prompt and seach the promot in the elastice search index.
Ruby - 3.0.0
Rails - 7.1.3
Postgres official image: postgres:12
Elasticseach image: docker.elastic.co/elasticsearch/elasticsearch:8.12.2
Currently the system does not have any password protection.
The database and elastic container is also not password protected.
Production setup is not done.
Rspec or any test suit has not yet added.
To run the application, the system should have docker installed.
- To run the postgres and elasticsearch container
$ docker compose up
- To run the application, rails application will run outside the container
$ rails s
- For postgres database setup, to create DB in the postgres
$ rails db:setup
and optional$ rails db:migrate
- To populate the elasticsearch's index
$ rails db:seed
This will pull up data from the dataset of huggingface and will create index nameduser_prompts
in elasticsearch and will dump data into the created index.
Postgres has mapped 5434
port to 5432
port of postgres container.
This is currently an unprotected database without username and password.
One table name user_prompts
this will store the search history.
UserPrompt(id: integer, text: string, created_at: datetime, updated_at: datetime)
Elastic has mapped 9201
port to 9200
port of elasticsearch container.
This is currently an unprotected database without username and password.
Gems for the elasticsearch
gem 'elasticsearch-model'
gem 'elasticsearch-rails'
'UserPrompt' is model mapped to search the query to elasticsearch index.
'UserPrompt' will also save the query to the postgresql table(db name: elastic_prompt_development).
{
"_index": "user_prompts",
"_id": "0",
"_version": 1,
"_seq_no": 0,
"_primary_term": 1,
"found": true,
"_source": {
"prompt": "realistic car 3 d render sci - fi car and sci - fi robotic factory structure in the coronation of napoleon painting and digital billboard with point cloud in the middle, unreal engine 5, keyshot, octane, artstation trending, ultra high detail, ultra realistic, cinematic, 8 k, 1 6 k, in style of zaha hadid, in style of nanospace michael menzelincev, in style of lee souder, in plastic, dark atmosphere, tilt shift, depth of field,"
}
}