search index
This commit is contained in:
@@ -69,14 +69,8 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<form method="GET" on:submit={search}>
|
<form method="GET" on:submit={search}>
|
||||||
{#if schema.fields[0]?.name}
|
<input type="search" name="filter[search_regex]" placeholder="Search"
|
||||||
<input type="search" name="filter[data.{schema.fields[0].name }_regex]" placeholder="Search"
|
|
||||||
class="form-control" required>
|
class="form-control" required>
|
||||||
{:else}
|
|
||||||
<input type="search" name="filter[_file.originalName_regex]" placeholder="Search"
|
|
||||||
class="form-control" required>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration {
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
Schema::table('records', function (Blueprint $table) {
|
||||||
|
$table->text('search')->default("");
|
||||||
|
$table->index('search');
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('records', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('search');
|
||||||
|
$table->dropIndex('search');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -214,7 +214,6 @@ class RecordController extends Controller
|
|||||||
->parentsLimit(100)
|
->parentsLimit(100)
|
||||||
->run();
|
->run();
|
||||||
|
|
||||||
|
|
||||||
if ($graph->records->isEmpty()) {
|
if ($graph->records->isEmpty()) {
|
||||||
return $this->svelte->render(
|
return $this->svelte->render(
|
||||||
layout: "channel",
|
layout: "channel",
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ final class FilterParser
|
|||||||
"eqfalse" => false,
|
"eqfalse" => false,
|
||||||
"netrue" => true,
|
"netrue" => true,
|
||||||
"nefalse" => false,
|
"nefalse" => false,
|
||||||
"regex" => "%{$value}%",
|
"regex" => "%" . strtolower($value) . "%",
|
||||||
"gt" => is_numeric($value) ? floatval($value) : $value,
|
"gt" => is_numeric($value) ? floatval($value) : $value,
|
||||||
"gte" => is_numeric($value) ? floatval($value) : $value,
|
"gte" => is_numeric($value) ? floatval($value) : $value,
|
||||||
"lt" => is_numeric($value) ? floatval($value) : $value,
|
"lt" => is_numeric($value) ? floatval($value) : $value,
|
||||||
|
|||||||
@@ -148,7 +148,6 @@ final class Query
|
|||||||
}
|
}
|
||||||
|
|
||||||
$query = $this->orderByQuery($query);
|
$query = $this->orderByQuery($query);
|
||||||
|
|
||||||
return $query->get()->map(function ($r) {
|
return $query->get()->map(function ($r) {
|
||||||
$r->isRoot = true;
|
$r->isRoot = true;
|
||||||
return $r;
|
return $r;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace Lucent\Record;
|
|||||||
|
|
||||||
use JsonSerializable;
|
use JsonSerializable;
|
||||||
use stdClass;
|
use stdClass;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class Record implements JsonSerializable
|
class Record implements JsonSerializable
|
||||||
{
|
{
|
||||||
@@ -23,6 +24,7 @@ class Record implements JsonSerializable
|
|||||||
|
|
||||||
public function toDB(): array
|
public function toDB(): array
|
||||||
{
|
{
|
||||||
|
$searchIndex = trim(Str::lower(collect($this->data)->values()->join(" ")." ". $this->_file?->originalName ?? ""));
|
||||||
return [
|
return [
|
||||||
"id" => $this->id,
|
"id" => $this->id,
|
||||||
"status" => $this->status->value,
|
"status" => $this->status->value,
|
||||||
@@ -30,6 +32,7 @@ class Record implements JsonSerializable
|
|||||||
"_sys" => json_encode($this->_sys),
|
"_sys" => json_encode($this->_sys),
|
||||||
"_file" => json_encode($this->_file),
|
"_file" => json_encode($this->_file),
|
||||||
"data" => json_encode($this->data),
|
"data" => json_encode($this->data),
|
||||||
|
"search" => $searchIndex,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,5 +64,4 @@ class Record implements JsonSerializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ class RecordRepo
|
|||||||
public static function create(Record $record): void
|
public static function create(Record $record): void
|
||||||
{
|
{
|
||||||
$recordToDB = $record->toDB();
|
$recordToDB = $record->toDB();
|
||||||
|
|
||||||
DB::table("records")->insert($recordToDB);
|
DB::table("records")->insert($recordToDB);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user