SQL
SQL
ParadeDB comes with a helpful procedure that creates a table populated with mock data to help
you get started. Run the following command to create this table.Then, inspect the first 3 rows:Next, let’s create a BM25 index called You’re all set! Try running some queries.
Expected Response
search_idx on this table. A BM25 index is a covering index, which means that multiple columns can be included in the same index.As a general rule of thumb, any columns that you want to filter,
GROUP BY,
ORDER BY, or aggregate as part of a full text query should be added to the
index for faster performance.Note the mandatory
key_field option. See choosing a key
field for more
details.Django
Django
To start you’ll need a Django project with Psycopg and django-paradedb installed. Run the following to create one:In We can now add a model for ParadeDB’s built-in test table and BM25 index:Run the migrations to create the table and index:Now, open a Python shell with You’re all set! Try running some queries in your Python shell.
myproject/settings.py, add 'django.contrib.postgres' and 'myapp' to INSTALLED_APPS. Then, configure DATABASES["default"] to point to Postgres:myproject/settings.py
models.py
As a general rule of thumb, any columns that you want to filter,
GROUP BY,
ORDER BY, or aggregate as part of a full text query should be added to the
index for faster performance.Note the mandatory
key_field option. See choosing a key
field for more
details.python3 manage.py shell and run the following command to populate mock_items.SQLAlchemy
SQLAlchemy
To get started, install SQLAlchemy, Alembic, Psycopg, and sqlalchemy-paradedb.Initialize Alembic:Then update the Alembic configuration to point to your database:ParadeDB comes with a built-in test table that we’ll run our queries against. Create a Copy this configuration into your Next, add a migration to create the Update the generated migration to create the table:Then, run it with:Next, autogenerate a new migration to create the search index.The generated migration should look like this:Then run it with:Finally, run You’re all set! Try running some queries in your shell.
alembic.ini
models.py file with a model and search index for that table:As a general rule of thumb, any columns that you want to filter,
GROUP BY,
ORDER BY, or aggregate as part of a full text query should be added to the
index for faster performance.Note the mandatory
key_field option. See choosing a key
field for more
details.migrations/env.py:migrations/env.py
mock_items test table. Create a blank migration in 0001_create_mock_items_table.py by running the following command:0002_add_mock_items_search_index.py
python and execute the following:Rails
Rails
To get started, create a Rails app that uses PostgreSQL.Add the rails-paradedb gem to your Then install it:Update ParadeDB comes with a built-in test table that we’ll run our queries against. Generate a migration to create it:Update the generated migration to create Next, create a model for the Then, create a search index for that table in Generate a migration for the search index:Update the generated migration to create the index:Run the migrations:You’re all set! Open the Rails console and run some queries.
Gemfile:Gemfile
config/database.yml to point to your ParadeDB database:config/database.yml
mock_items:db/migrate/*_create_mock_items_table.rb
mock_items table in app/models/mock_item.rb:app/models/mock_item.rb
app/models/mock_item_index.rb:app/models/mock_item_index.rb
As a general rule of thumb, any columns that you want to filter,
GROUP BY,
ORDER BY, or aggregate as part of a full text query should be added to the
index for faster performance.Note the mandatory
key_field option. See choosing a key
field for more
details.db/migrate/*_create_mock_items_index.rb