From 7390178376fd143d5b1d8f34f7656317d79b0b16 Mon Sep 17 00:00:00 2001 From: yggverse Date: Thu, 21 Mar 2024 22:09:11 +0200 Subject: [PATCH] apply search options --- src/cli/document/search.php | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/cli/document/search.php b/src/cli/document/search.php index 0515b63..9d354a1 100644 --- a/src/cli/document/search.php +++ b/src/cli/document/search.php @@ -23,10 +23,33 @@ $index = $client->index( $config->manticore->index->document->name ); +// Init search query +$query = $index->search( + $argv[1] +); + +// Apply search options (e.g. field_weights) +foreach ($config->webui->search->options as $key => $value) +{ + if (is_int($value) || is_string($value)) + { + $query->option( + $key, + $value + ); + } + + else + { + $query->option( + $key, + (array) $value + ); + } +} + // Search -foreach($index->search($argv[1]) - ->limit($argv[2] ? $argv[2] : 10) - ->get() as $result) +foreach($query->limit($argv[2] ? $argv[2] : 10)->get() as $result) { var_dump( $result