@@ -70,6 +70,39 @@ products_bm25_idx = Index(
7070)
7171```
7272
73+ Tokenizer configs can use a Django/Rails-style structured shape:
74+
75+ ``` python
76+ products_bm25_idx = Index(
77+ " products_bm25_idx" ,
78+ indexing.BM25Field(Product.id),
79+ indexing.BM25Field(
80+ Product.description,
81+ tokenizer = indexing.tokenize.from_config(
82+ {
83+ " tokenizer" : " simple" ,
84+ " filters" : [" lowercase" , " stemmer" ],
85+ " stemmer" : " english" ,
86+ " alias" : " description_simple" ,
87+ }
88+ ),
89+ ),
90+ indexing.BM25Field(
91+ Product.description,
92+ tokenizer = indexing.tokenize.from_config(
93+ {
94+ " tokenizer" : " ngram" ,
95+ " args" : [3 , 8 ],
96+ " named_args" : {" prefix_only" : True },
97+ " alias" : " description_ngram" ,
98+ }
99+ ),
100+ ),
101+ postgresql_using = " bm25" ,
102+ postgresql_with = {" key_field" : " id" },
103+ )
104+ ```
105+
73106## Query APIs
74107
75108- Basic predicates: ` match_all ` , ` match_any ` , ` term ` , ` phrase ` , ` fuzzy ` , ` regex ` , ` all `
@@ -108,8 +141,24 @@ Usage:
108141
109142``` python
110143op.create_bm25_index(" products_bm25_idx" , " products" , [" id" , " description" ], key_field = " id" )
144+ # Tokenizer-aware expressions are supported too:
145+ op.create_bm25_index(
146+ " products_bm25_idx" ,
147+ " products" ,
148+ [" id" , " ((description)::pdb.simple('alias=description_simple,lowercase=true'))" ],
149+ key_field = " id" ,
150+ )
151+ # Schema-aware operations:
152+ op.create_bm25_index(
153+ " products_bm25_idx" ,
154+ " products" ,
155+ [" id" , " description" ],
156+ key_field = " id" ,
157+ table_schema = " search" ,
158+ )
111159op.reindex_bm25(" products_bm25_idx" , concurrently = True )
112- op.drop_bm25_index(" products_bm25_idx" , if_exists = True )
160+ op.reindex_bm25(" products_bm25_idx" , concurrently = True , schema = " search" )
161+ op.drop_bm25_index(" products_bm25_idx" , if_exists = True , schema = " search" )
113162```
114163
115164## Validation and Guardrails
0 commit comments