/* 
This file is auto generated by pgrx.

The ordering of items is not stable, it is driven by a dependency graph.
*/

-- pg_bm25/src/lib.rs:13
-- bootstrap
GRANT ALL ON SCHEMA paradedb TO PUBLIC;


-- pg_bm25/src/operator/mod.rs:5
-- pg_bm25::operator::search_tantivy
CREATE  FUNCTION paradedb."search_tantivy"(
	"element" anyelement, /* pgrx::datum::anyelement::AnyElement */
	"query" TEXT /* &str */
) RETURNS bool /* bool */
IMMUTABLE STRICT PARALLEL SAFE
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'search_tantivy_wrapper';

-- pg_bm25/src/api/index.rs:9
-- pg_bm25::api::index::schema_bm25
CREATE  FUNCTION paradedb."schema_bm25"(
	"index_name" TEXT /* &str */
) RETURNS TABLE (
	"name" TEXT,  /* alloc::string::String */
	"field_type" TEXT,  /* alloc::string::String */
	"stored" bool,  /* bool */
	"indexed" bool,  /* bool */
	"fast" bool,  /* bool */
	"fieldnorms" bool,  /* bool */
	"expand_dots" bool,  /* core::option::Option<bool> */
	"tokenizer" TEXT,  /* core::option::Option<alloc::string::String> */
	"record" TEXT,  /* core::option::Option<alloc::string::String> */
	"normalizer" TEXT  /* core::option::Option<alloc::string::String> */
)
STRICT
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'schema_bm25_wrapper';

-- pg_bm25/src/api/search.rs:8
-- pg_bm25::api::search::rank_bm25
CREATE  FUNCTION paradedb."rank_bm25"(
	"ctid" tid /* core::option::Option<pgrx_pg_sys::pg15::ItemPointerData> */
) RETURNS real /* f32 */
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'rank_bm25_wrapper';

-- pg_bm25/src/api/search.rs:27
-- pg_bm25::api::search::minmax_bm25
CREATE  FUNCTION paradedb."minmax_bm25"(
	"ctid" tid, /* pgrx_pg_sys::pg15::ItemPointerData */
	"index_name" TEXT, /* &str */
	"query" TEXT /* &str */
) RETURNS real /* f32 */
STRICT
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'minmax_bm25_wrapper';

-- pg_bm25/src/api/search.rs:16
-- pg_bm25::api::search::highlight_bm25
CREATE  FUNCTION paradedb."highlight_bm25"(
	"ctid" tid, /* core::option::Option<pgrx_pg_sys::pg15::ItemPointerData> */
	"field_name" TEXT /* alloc::string::String */
) RETURNS TEXT /* alloc::string::String */
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'highlight_bm25_wrapper';

-- pg_bm25/src/index_access/mod.rs:19
-- pg_bm25::index_access::bm25_handler

CREATE FUNCTION bm25_handler(internal) RETURNS index_am_handler PARALLEL SAFE IMMUTABLE STRICT COST 0.0001 LANGUAGE c AS 'MODULE_PATHNAME', 'bm25_handler_wrapper';
CREATE ACCESS METHOD bm25 TYPE INDEX HANDLER bm25_handler;
COMMENT ON ACCESS METHOD bm25 IS 'bm25 index access method';




-- pg_bm25/src/api/aggregation.rs:11
-- pg_bm25::api::aggregation::aggregation
CREATE  FUNCTION paradedb."aggregation"(
	"index_name" TEXT, /* &str */
	"query" TEXT /* &str */
) RETURNS jsonb /* pgrx::datum::json::JsonB */
STRICT
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'aggregation_wrapper';

-- pg_bm25/src/operator/mod.rs:136

CREATE OPERATOR pg_catalog.@@@ (
    PROCEDURE = search_tantivy,
    LEFTARG = anyelement,
    RIGHTARG = text
);

CREATE OPERATOR CLASS anyelement_bm25_ops DEFAULT FOR TYPE anyelement USING bm25 AS
    OPERATOR 1 pg_catalog.@@@(anyelement, text),
    STORAGE anyelement;



-- pg_bm25/src/lib.rs:14
CREATE TABLE paradedb.mock_items (
    id SERIAL PRIMARY KEY,
    description TEXT,
    rating INTEGER CHECK (
        rating BETWEEN 1
        AND 5
    ),
    category VARCHAR(255),
    in_stock BOOLEAN,
    metadata JSONB
);

INSERT INTO paradedb.mock_items (description, rating, category, in_stock, metadata)
VALUES
    ('Ergonomic metal keyboard', 4, 'Electronics', true, '{"color": "Silver", "location": "United States"}'::JSONB),
    ('Plastic Keyboard', 4, 'Electronics', false, '{"color": "Black", "location": "Canada"}'::JSONB),
    ('Sleek running shoes', 5, 'Footwear', true, '{"color": "Blue", "location": "China"}'::JSONB),
    ('White jogging shoes', 3, 'Footwear', false, '{"color": "White", "location": "United States"}'::JSONB),
    ('Generic shoes', 4, 'Footwear', true, '{"color": "Brown", "location": "Canada"}'::JSONB),
    ('Compact digital camera', 5, 'Photography', false, '{"color": "Black", "location": "China"}'::JSONB),
    ('Hardcover book on history', 2, 'Books', true, '{"color": "Brown", "location": "United States"}'::JSONB),
    ('Organic green tea', 3, 'Groceries', true, '{"color": "Green", "location": "Canada"}'::JSONB),
    ('Modern wall clock', 4, 'Home Decor', false, '{"color": "Silver", "location": "China"}'::JSONB),
    ('Colorful kids toy', 1, 'Toys', true, '{"color": "Multicolor", "location": "United States"}'::JSONB),
    ('Soft cotton shirt', 5, 'Apparel', true, '{"color": "Blue", "location": "Canada"}'::JSONB),
    ('Innovative wireless earbuds', 5, 'Electronics', true, '{"color": "Black", "location": "China"}'::JSONB),
    ('Sturdy hiking boots', 4, 'Footwear', true, '{"color": "Brown", "location": "United States"}'::JSONB),
    ('Elegant glass table', 3, 'Furniture', true, '{"color": "Clear", "location": "Canada"}'::JSONB),
    ('Refreshing face wash', 2, 'Beauty', false, '{"color": "White", "location": "China"}'::JSONB),
    ('High-resolution DSLR', 4, 'Photography', true, '{"color": "Black", "location": "United States"}'::JSONB),
    ('Paperback romantic novel', 3, 'Books', true, '{"color": "Multicolor", "location": "Canada"}'::JSONB),
    ('Freshly ground coffee beans', 5, 'Groceries', true, '{"color": "Brown", "location": "China"}'::JSONB),
    ('Artistic ceramic vase', 4, 'Home Decor', false, '{"color": "Multicolor", "location": "United States"}'::JSONB),
    ('Interactive board game', 3, 'Toys', true, '{"color": "Multicolor", "location": "Canada"}'::JSONB),
    ('Slim-fit denim jeans', 5, 'Apparel', false, '{"color": "Blue", "location": "China"}'::JSONB),
    ('Fast charging power bank', 4, 'Electronics', true, '{"color": "Black", "location": "United States"}'::JSONB),
    ('Comfortable slippers', 3, 'Footwear', true, '{"color": "Brown", "location": "Canada"}'::JSONB),
    ('Classic leather sofa', 5, 'Furniture', false, '{"color": "Brown", "location": "China"}'::JSONB),
    ('Anti-aging serum', 4, 'Beauty', true, '{"color": "White", "location": "United States"}'::JSONB),
    ('Portable tripod stand', 4, 'Photography', true, '{"color": "Black", "location": "Canada"}'::JSONB),
    ('Mystery detective novel', 2, 'Books', false, '{"color": "Multicolor", "location": "China"}'::JSONB),
    ('Organic breakfast cereal', 5, 'Groceries', true, '{"color": "Brown", "location": "United States"}'::JSONB),
    ('Designer wall paintings', 5, 'Home Decor', true, '{"color": "Multicolor", "location": "Canada"}'::JSONB),
    ('Robot building kit', 4, 'Toys', true, '{"color": "Multicolor", "location": "China"}'::JSONB),
    ('Sporty tank top', 4, 'Apparel', true, '{"color": "Blue", "location": "United States"}'::JSONB),
    ('Bluetooth-enabled speaker', 3, 'Electronics', true, '{"color": "Black", "location": "Canada"}'::JSONB),
    ('Winter woolen socks', 5, 'Footwear', false, '{"color": "Gray", "location": "China"}'::JSONB),
    ('Rustic bookshelf', 4, 'Furniture', true, '{"color": "Brown", "location": "United States"}'::JSONB),
    ('Moisturizing lip balm', 4, 'Beauty', true, '{"color": "Pink", "location": "Canada"}'::JSONB),
    ('Lightweight camera bag', 5, 'Photography', false, '{"color": "Black", "location": "China"}'::JSONB),
    ('Historical fiction book', 3, 'Books', true, '{"color": "Multicolor", "location": "United States"}'::JSONB),
    ('Pure honey jar', 4, 'Groceries', true, '{"color": "Yellow", "location": "Canada"}'::JSONB),
    ('Handcrafted wooden frame', 5, 'Home Decor', false, '{"color": "Brown", "location": "China"}'::JSONB),
    ('Plush teddy bear', 4, 'Toys', true, '{"color": "Brown", "location": "United States"}'::JSONB),
    ('Warm woolen sweater', 3, 'Apparel', false, '{"color": "Red", "location": "Canada"}'::JSONB);

