Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
AI & KI NachrichtenHow to Combine Traditional Machine Learning with Agentic Reasoning(10.09.2026 um 14:00 Uhr)
AI & KI NachrichtenFine-Tuning Agentic AI: A Practical Guide(11.09.2026 um 14:00 Uhr)
AI & KI NachrichtenA Gentle Introduction to Model Distillation(14.09.2026 um 14:42 Uhr)
AI & KI NachrichtenThe Roadmap to Mastering Voice Agents(16.09.2026 um 14:00 Uhr)
Sichere ProgrammierungWhat happens when an AI doesn't know the answer?(23.09.2026 um 03:02 Uhr)
Sichere ProgrammierungAmbiguous submission outcomes should never be retried(23.09.2026 um 03:03 Uhr)
Sichere ProgrammierungI let git history grade six famous open-source projects(23.09.2026 um 03:11 Uhr)
Sichere ProgrammierungI'm changing my logo(23.09.2026 um 03:11 Uhr)
AI & KI NachrichtenHow to Combine Traditional Machine Learning with Agentic Reasoning(10.09.2026 um 14:00 Uhr)
AI & KI NachrichtenFine-Tuning Agentic AI: A Practical Guide(11.09.2026 um 14:00 Uhr)
AI & KI NachrichtenA Gentle Introduction to Model Distillation(14.09.2026 um 14:42 Uhr)
AI & KI NachrichtenThe Roadmap to Mastering Voice Agents(16.09.2026 um 14:00 Uhr)
Sichere ProgrammierungWhat happens when an AI doesn't know the answer?(23.09.2026 um 03:02 Uhr)
Sichere ProgrammierungAmbiguous submission outcomes should never be retried(23.09.2026 um 03:03 Uhr)
Sichere ProgrammierungI let git history grade six famous open-source projects(23.09.2026 um 03:11 Uhr)
Sichere ProgrammierungI'm changing my logo(23.09.2026 um 03:11 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Store and search chunks in Laravel with Meilisearch and Larameili

Many times, you have to split documents into chunks, embed them, and push them into Meilisearch. Now the chunks live in the index and only in the index. There is no reason to keep a copy in your database: nothing joins a chunk, nothing…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

Many times, you have to split documents into chunks, embed them, and push them into Meilisearch. Now the chunks live in the index and only in the index. There is no reason to keep a copy in your database: nothing joins a chunk, nothing edits one by hand, and the only question you ever ask is which chunks are relevant to this query, within this filter.



The awkward part is querying them from Laravel. Scout wants to mirror an Eloquent model into the index, which is backwards here. So you end up talking to the raw Meilisearch client, building filter strings by hand and mapping arrays back into something usable.



Larameili is for exactly this. It gives a Meilisearch index an Active Record model, so the chunks read like Eloquent even though they never touch your database.






How to install



As usually, use composer, and the service provider auto-registers:




composer require edulazaro/larameili






It reads the same MEILISEARCH_HOST and MEILISEARCH_KEY your app already uses.






The model is the index



A model maps to one index. Declare the index name, the fields to filter on, and an embedder if you want hybrid search.




namespace App\Meili;

use EduLazaro\Larameili\Meili;

/**
* @property string $id
* @property int $document_id
* @property string $content
* @property string $type
*/

class Chunk extends Meili
{
protected static string $index = 'chunks';

protected static array $searchable = ['content'];
protected static array $filterable = ['document_id', 'type'];

protected static array $embedders = [
'default' => ['source' => 'openAi', 'model' => 'text-embedding-3-small'],
];
}









Push the settings



The $filterable and $embedders you declared live in code until you sync them to the engine. List the model in config/larameili.php and run the command, which creates the index and applies the settings.




php artisan meili:sync









Import the chunks in bulk



An importer sends thousands of chunks. import() streams them in batches and waits for each one, so a long import never outruns the engine, and it is memory-safe over a generator.




Chunk::import($documentChunks, batchSize: 500);






There are also insert(), updateMany() for partial updates, and deleteWhere() to drop a document's chunks by filter.




Chunk::deleteWhere("document_id = {$document->id}");









Search, keyword then hybrid



The query builder compiles to Meilisearch parameters and hydrates the hits back into Chunk models. Start with a keyword search inside a filter.




$hits = Chunk::query()
->where('type', 'body')
->search('cancellation policy');






Because the index has an embedder, semantic() turns it into a hybrid search: Meilisearch runs the keyword and the vector search together and fuses the rankings. 0 is keyword only, 1 is vector only.




$hits = Chunk::query()
->where('type', 'body')
->semantic(0.7)
->search('how do I get my money back');









Filter and paginate



Filters map to Meilisearch's syntax, and paginate() returns a Laravel LengthAwarePaginator with an exact total, so it drops straight into a Blade view.




$page = Chunk::query()
->whereIn('document_id', [1, 2, 3])
->where('type', 'body')
->paginate(20);

$page->total(); // exact
$page->links();









Back to the Eloquent record



A chunk belongs to a Document that does live in your database. Meilisearch has no joins, so this is a resolver: it looks the Eloquent model up by the foreign key stored on the chunk.




use EduLazaro\Larameili\Relations\BelongsToEloquent;

class Chunk extends Meili
{
public function document(): BelongsToEloquent
{
return $this->belongsToEloquent(Document::class, foreignKey: 'document_id', ownerKey: 'id');
}
}






Read it as a property and it resolves lazily. Eager-load it on a search with with(), so every hit is resolved in one query instead of one per hit.




$hits = Chunk::query()
->semantic(0.7)
->with('document') // one whereIn for every hit
->search('how do I get my money back');

$hits->first()->document->title; // a normal Eloquent model









And that's it



The chunks stay in Meilisearch, where they belong, and you query them with a model instead of a raw client: filters, hybrid search, pagination, and a link back to the records that do live in your database. Your relational schema keeps the entities that earn a table, and the search documents stop pretending to be one of them.



👉 Package on Packagist: packagist.org/packages/edulazaro/larameili

👉 Source on GitHub: github.com/edulazaro/larameili

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-17636 | IBM Financial Transaction Manager (FTM) for RedHat OpenShift could allow…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick