Skip to content

Read Primitives — Phrase Text Search

Read Primitives benchmark · all Read Primitives queries

Phrase-based text search with ranking

Representative SQL

Rendered in the benchmark’s native SQL with default parameters (no dialect translation available).

SELECT
s_suppkey,
s_name,
s_comment,
MATCH(s_comment) AGAINST('"Customer Complaints"' IN BOOLEAN MODE) AS phrase_match_score
FROM supplier
WHERE
MATCH(s_comment) AGAINST('"Customer Complaints"' IN BOOLEAN MODE)
ORDER BY
phrase_match_score DESC

Representative DataFrame

Expression family (Polars, PySpark, DataFusion), default parameters.

def fulltext_phrase_search_expression_impl(ctx: DataFrameContext) -> Any:
supplier = ctx.get_table("supplier")
col = ctx.col
return (
supplier.filter(col("s_comment").str.to_lowercase().str.contains("customer complaints"))
.with_columns(
col("s_comment")
.str.to_lowercase()
.str.contains("customer complaints")
.cast(int)
.alias("phrase_match_score")
)
.select("s_suppkey", "s_name", "s_comment", "phrase_match_score")
.sort("phrase_match_score", descending=True)
)

Get the exact query for your run

The blocks above are representative. To get the precise statement a specific platform runs at a specific scale, substitute your own values:

from benchbox import ReadPrimitives
bench = ReadPrimitives(scale_factor=0.01) # your scale factor
queries = bench.get_queries(dialect="datafusion") # your platform's dialect; drop dialect= for native SQL
print(queries['fulltext_phrase_search'])

For the DataFrame form:

from benchbox.core.query_catalog import get_dataframe_render
print(get_dataframe_render('read_primitives', 'fulltext_phrase_search', family="expression").source) # or family="pandas"

Source

Query text: benchbox/core/read_primitives/queries.py