Skip to content

Commit 5e62727

Browse files
author
Amine
committed
Add infix parameter
1 parent e823438 commit 5e62727

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/Engines/TypesenseEngine.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
*/
@@ -242,6 +247,7 @@ private function buildSearchParams(Builder $builder, int $page, int|null $perPag
242247
'prioritize_exact_match' => $this->prioritizeExactMatch,
243248
'enable_overrides' => $this->enableOverrides,
244249
'highlight_affix_num_tokens' => $this->highlightAffixNumTokens,
250+
'infix' => $this->infix,
245251
];
246252

247253
if ($this->limitHits > 0) {
@@ -770,6 +776,21 @@ public function setHighlightAffixNumTokens(int $highlightAffixNumTokens): static
770776
return $this;
771777
}
772778

779+
/**
780+
* Set the infix search option for the field.
781+
*
782+
* @param string $infix The infix search option to enable for the field.
783+
* Possible values: "off" (disabled, default), "always" (along with regular search),
784+
* "fallback" (if regular search produces no results).
785+
* @return $this
786+
*/
787+
public function setInfix(string $infix): static
788+
{
789+
$this->infix = $infix;
790+
791+
return $this;
792+
}
793+
773794
/**
774795
* Field values under this length will be fully highlighted, instead of showing a snippet of relevant portion.
775796
*

src/Mixin/BuilderMixin.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,21 @@ public function setHighlightAffixNumTokens(): Closure
271271
};
272272
}
273273

274+
/**
275+
* @param string $infix
276+
*
277+
* @return \Closure
278+
*/
279+
public function setInfix(): Closure
280+
{
281+
return function (string $infix) {
282+
$this->engine()
283+
->setInfix($infix);
284+
285+
return $this;
286+
};
287+
}
288+
274289
/**
275290
* @param int $snippetThreshold
276291
*

0 commit comments

Comments
 (0)