ActiveContext Postgres indexer support
What does this MR do and why?
Adds the ability to pass connection details to the elasticsearch-indexer for the postgres adapter.
References
How to set up and validate locally
- Checkout feat: postgres indexer (gitlab-elasticsearch-indexer!832) branch and run
make - Run postgres
docker run -p 5432:5432 --name pgvector17 -e POSTGRES_PASSWORD=password pgvector/pgvector:pg17
- Create the vector extension
psql -h localhost -p 5432 -U postgres
CREATE EXTENSION vector;
- Create a postgres connection
connection = Ai::ActiveContext::Connection.create!(
name: "postgres",
options: { host: 'localhost', port: 5432, username: 'postgres', password: 'password' },
adapter_class: "ActiveContext::Databases::Postgresql::Adapter"
)
connection.activate!
- Run migration worker on repeat
::Ai::ActiveContext::MigrationWorker.new.perform
- Create enabled namespaces
Ai::ActiveContext::Code::SchedulingWorker.new.perform("create_enabled_namespace")
- Trigger indexing for a project
::Ai::ActiveContext::Code::AdHocIndexingWorker.new.perform(1000000)
- Note that the repo files were chunked and indexed
- Update a file and note that the chunks are representative (orphaned data deleted)
- Run the deleter and note that the chunks were deleted
Ai::ActiveContext::Code::Deleter.run!(Ai::ActiveContext::Code::Repository.find_by(project_id:
1000000))
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.