GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - zig-utils/zig-search-engine: Search-engine integrations for Zig services.

BranchesTags
Open more actions menu

Latest commit

 

History

3 Commits
3 Commits

Folders and files

NameName
Last commit message
Last commit date
src
src
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
build.zig
build.zig
 
 
build.zig.zon
build.zig.zon
 
 

Repository files navigation

zig-search-engine

Search-engine integrations for Zig services — a Zig take on @stacksjs/search-engine.

Collections are declared as model-style Schemas (searchable / filterable / sortable attributes), and a driver turns that declaration into the engine-native data structure. Typesense is the first driver.

Usage

const se = @import("search-engine");

// The model: which attributes are searchable, filterable (facets), sortable.
const messages_schema = se.Schema{
    .name = "messages",
    .searchable = &.{ .{ .name = "subject" }, .{ .name = "body" } },
    .filterable = &.{ .{ .name = "username" }, .{ .name = "mailbox" } },
    .sortable = &.{ .{ .name = "date", .type = .int64 } },
};

const engine = se.Typesense.init(.{ .api_key = key }); // host/port default to 127.0.0.1:8108
try engine.ensureCollection(allocator, messages_schema);

// Index a document
var doc = se.DocBuilder.init(allocator);
defer doc.deinit();
try doc.putString("id", "msg-1");
try doc.putString("subject", "hello world");
const json = try doc.toOwned();
defer allocator.free(json);
try engine.upsertDocument(allocator, "messages", json);

// Search
var result = try engine.search(allocator, "messages", .{
    .query = "hello",
    .query_by = "subject,body",
    .filter_by = "username:=`chris`",
});
defer result.deinit();

var it = result.hits();
while (it.next()) |hit| {
    std.debug.print("{s}\n", .{se.SearchResponse.docString(hit, "subject")});
}

Also provided: importDocuments (JSONL bulk upsert), deleteDocument, deleteCollection, healthy, and JSON/URL encoding helpers under se.http.

Requirements

  • Zig 0.16.0-dev+ (developed against 0.17.0-dev)
  • libc (the HTTP client uses libc sockets)

Install

zig fetch --save https://github.com/zig-utils/zig-search-engine/archive/<commit>.tar.gz

Then in build.zig:

const search_engine = b.dependency("search_engine", .{ .target = target, .optimize = optimize });
exe.root_module.addImport("search-engine", search_engine.module("search-engine"));

Community

For help, discussion about best practices, or any other conversation that would benefit from being searchable:

Discussions on GitHub

For casual chit-chat with others using this package:

Join the zig-utils Discord Server

License

MIT

About

Search-engine integrations for Zig services.

Resources

Readme
MIT license
Activity
Custom properties

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.