Skip to main content
Now that your environment is configured, select the codetab for your tool and run some queries. We’re now ready to execute a basic text search query. We’ll look for matches where description matches running shoes where rating is greater than 2.
Expected Response
||| is ParadeDB’s custom match disjunction operator, which means “find me all documents containing running OR shoes. If we want all documents containing running AND shoes, we can use ParadeDB’s &&& match conjunction operator.
Expected Response

BM25 Scoring

Next, let’s add BM25 scoring to the results, which sorts matches by relevance. To do this, we’ll use pdb.score.
Expected Response
Native vector search support for ParadeDB requires version 0.25.0 or above.
The mock_items table also contains an embedding column. Let’s execute the same query above, but order results by vector similarity instead of BM25 score:
Expected Response
Because embedding is part of the same index as description and rating, the entire query (the full-text match, the rating filter, and the nearest-neighbor ordering) executes inside the ParadeDB index. ParadeDB is the only Postgres index that can do this — every other Postgres vector index is a standalone index that requires separate pre/post filtering, which hurts performance and recall.

Top K Ordering

In addition to BM25 and vector similarity, ParadeDB is also optimized for quickly sorting by an arbitrary field, also known as a Top K query. In SQL, this means queries that contain an ORDER BY <field>...LIMIT:
Expected Response
The ordering field, in this case rating, must be indexed inside the ParadeDB index.

Highlighting

Finally, let’s also highlight the relevant portions of the documents that were matched. To do this, we’ll use pdb.snippet.
Expected Response

Facets

Faceted queries allow a single query to return both the Top K results and an aggregate value, which is more CPU-efficient than issuing two separate queries. For example, the following query returns the top 3 results as well as the total number of results matched.
Expected Response
That’s it! Next, let’s load your data to start running real queries.