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.Drizzle (JavaScript)
Drizzle (JavaScript)
To get started, create a TypeScript project with Drizzle, postgres.js, and @paradedb/drizzle-paradedb installed.Create a Create a Drizzle Kit configuration that points at the same database:Open a TypeScript REPL:Import your database connection, schema, and any helpers used by the setup and query snippets. The Node REPL does not support static Create and populate Now, in a separate terminal, push the Drizzle schema to create the BM25 index:To paste a formatted query snippet, enter editor mode:Paste the query body without its
db.ts file with your database connection and a schema for ParadeDB’s built-in test table:db.ts
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.drizzle.config.ts
import statements, so use dynamic imports here:mock_items:import lines. The helpers from those imports are already available from the dynamic imports above. Press Ctrl+D to run the pasted query.You’re all set! Try running some queries in the REPL.Django (Python)
Django (Python)
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 (Python)
SQLAlchemy (Python)
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 (Ruby)
Rails (Ruby)
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
Entity Framework Core (C#)
Entity Framework Core (C#)
To get started, create a .NET project with EF Core, Npgsql.EntityFrameworkCore.PostgreSQL, and ParadeDB.EntityFrameworkCore installed.Replace Create the EF Core migration:Open the generated migration in Then apply the migration:This creates You’re all set! Try running some queries by adding them to
This console app uses
OnConfiguring to keep the example self-contained. In
ASP.NET Core or another app with dependency injection, register ParadeDB
through UseNpgsql in Program.cs:Program.cs with a DbContext, model, and query scratchpad for ParadeDB’s built-in test table:Program.cs
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/*_CreateMockItems.cs and add this seed step to the end of the Up method:mock_items, the BM25 index, and loads the mock data. Now, run the query included in Program.cs:Program.cs.