Use this file to discover all available pages before exploring further.
This guide will walk you through setting up your environment to run queries against ParadeDB. Choose your preferred tool below:
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.
Next, let’s create a BM25 index called search_idx on this table. A BM25 index is a covering index, which means that multiple columns can be included in the same index.
CREATE INDEX search_idx ON mock_itemsUSING bm25 (id, description, category, rating, in_stock, created_at, metadata, weight_range)WITH (key_field='id');
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.
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.
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.
Copy this configuration into your migrations/env.py:
migrations/env.py
from logging.config import fileConfigfrom sqlalchemy import engine_from_config, textfrom sqlalchemy import poolfrom alembic import context# This import is required for autogenerated ParadeDB migrations# to work properly.import paradedb.sqlalchemy.alembic # noqa: F401from models import Baseconfig = context.configif config.config_file_name is not None: fileConfig(config.config_file_name)target_metadata = Base.metadata# The ParadeDB Docker image comes pre-bundled with some popular# extensions like PostGIS. PostGIS automatically creates a table# called `spatial_ref_sys`. This tells Alembic not to drop it even# though it isn't tracked in Alembic's metadata.IGNORED_TABLES = {"spatial_ref_sys"}def include_object(object, name, type_, reflected, compare_to): if type_ == "table" and reflected and name in IGNORED_TABLES: return False return Truedef run_migrations_offline() -> None: url = config.get_main_option("sqlalchemy.url") context.configure( url=url, target_metadata=target_metadata, literal_binds=True, dialect_opts={"paramstyle": "named"}, ) with context.begin_transaction(): context.run_migrations()def run_migrations_online() -> None: connectable = engine_from_config( config.get_section(config.config_ini_section, {}), prefix="sqlalchemy.", poolclass=pool.NullPool, ) with connectable.connect() as connection: # This prevents Alembic from modifying tables outside # of the `public` schema. connection.execute(text("SET search_path TO public")) connection.commit() context.configure( connection=connection, target_metadata=target_metadata, include_object=include_object, ) with context.begin_transaction(): context.run_migrations()if context.is_offline_mode(): run_migrations_offline()else: run_migrations_online()
Next, add a migration to create the mock_items test table. Create a blank migration in 0001_create_mock_items_table.py by running the following command:
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.