@@ -107,6 +107,11 @@ class TypesenseEngine extends Engine
107107 */
108108 private string $ facetQuery = '' ;
109109
110+ /**
111+ * @var string
112+ */
113+ private string $ infix = 'off ' ;
114+
110115 /**
111116 * @var array
112117 */
@@ -233,14 +238,6 @@ public function paginate(Builder $builder, $perPage, $page): mixed
233238 private function buildSearchParams (Builder $ builder , int $ page , int |null $ perPage ): array
234239 {
235240 $ params = [
236- 'q ' => $ builder ->query ,
237- 'query_by ' => implode (', ' , $ builder ->model ->typesenseQueryBy ()),
238- 'filter_by ' => $ this ->filters ($ builder ),
239- 'per_page ' => $ perPage ,
240- 'page ' => $ page ,
241- 'highlight_start_tag ' => $ this ->startTag ,
242- 'highlight_end_tag ' => $ this ->endTag ,
243- 'exhaustive_search ' => $ this ->exhaustiveSearch ,
244241 'q ' => $ builder ->query ,
245242 'query_by ' => implode (', ' , $ builder ->model ->typesenseQueryBy ()),
246243 'filter_by ' => $ this ->filters ($ builder ),
@@ -255,6 +252,7 @@ private function buildSearchParams(Builder $builder, int $page, int|null $perPag
255252 'prioritize_exact_match ' => $ this ->prioritizeExactMatch ,
256253 'enable_overrides ' => $ this ->enableOverrides ,
257254 'highlight_affix_num_tokens ' => $ this ->highlightAffixNumTokens ,
255+ 'infix ' => $ this ->infix ,
258256 ];
259257
260258 if ($ this ->limitHits > 0 ) {
@@ -787,6 +785,21 @@ public function setHighlightAffixNumTokens(int $highlightAffixNumTokens): static
787785 return $ this ;
788786 }
789787
788+ /**
789+ * Set the infix search option for the field.
790+ *
791+ * @param string $infix The infix search option to enable for the field.
792+ * Possible values: "off" (disabled, default), "always" (along with regular search),
793+ * "fallback" (if regular search produces no results).
794+ * @return $this
795+ */
796+ public function setInfix (string $ infix ): static
797+ {
798+ $ this ->infix = $ infix ;
799+
800+ return $ this ;
801+ }
802+
790803 /**
791804 * Field values under this length will be fully highlighted, instead of showing a snippet of relevant portion.
792805 *
0 commit comments