Back to Paradedb

Source Code

docs/documentation/tokenizers/available-tokenizers/source-code.mdx

0.23.4676 B
Original Source

The source code tokenizer is intended for tokenizing code. In addition to splitting on whitespace, punctuation, and symbols, it also splits on common casing conventions like camel case and snake case. For instance, text like my_variable or myVariable would get split into my and variable.

sql
CREATE INDEX search_idx ON mock_items
USING bm25 (id, (description::pdb.source_code))
WITH (key_field='id');

To get a feel for this tokenizer, run the following command and replace the text with your own:

sql
SELECT 'let my_variable = 2;'::pdb.source_code::text[];
ini
        text
---------------------
 {let,my,variable,2}
(1 row)