{"id":21840482,"url":"https://github.com/rubiojr/hlx","last_synced_at":"2026-05-16T13:36:10.593Z","repository":{"id":260538103,"uuid":"881556421","full_name":"rubiojr/hlx","owner":"rubiojr","description":"A simple, type-safe, full-text document search library for Go powered by SQLite FTS5.","archived":false,"fork":false,"pushed_at":"2025-06-13T22:35:21.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-13T23:25:48.150Z","etag":null,"topics":["fts5","golang","sqlite"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rubiojr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-10-31T20:01:43.000Z","updated_at":"2025-06-13T22:35:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"c12c83cd-1bdb-4d18-a295-4317db6b416f","html_url":"https://github.com/rubiojr/hlx","commit_stats":null,"previous_names":["rubiojr/hlx"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/rubiojr/hlx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubiojr%2Fhlx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubiojr%2Fhlx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubiojr%2Fhlx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubiojr%2Fhlx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubiojr","download_url":"https://codeload.github.com/rubiojr/hlx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubiojr%2Fhlx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33104665,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T04:41:52.686Z","status":"ssl_error","status_checked_at":"2026-05-16T04:41:52.009Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fts5","golang","sqlite"],"created_at":"2024-11-27T21:26:28.604Z","updated_at":"2026-05-16T13:36:10.586Z","avatar_url":"https://github.com/rubiojr.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hlx\n\nA simple, type-safe, full-text document search library for Go powered by SQLite FTS5.\n\n## Features\n\n- Type-safe document storage and retrieval using Go generics\n- Full-text search capabilities using SQLite FTS5\n- Automatic UUID generation for documents without IDs\n- Support for in-memory and file-based databases\n- Simple and intuitive API\n- Relatively fast. hlx can index [thousands of documents per second](/performance.txt) in a modern laptop and perform sub-second searches, thanks to the blazing fast SQLite FTS5 engine.\n\n## Installation\n\n```bash\ngo get github.com/rubiojr/hlx\n```\n\n## Usage\n\n\u003e[!IMPORTANT]\n\u003e When building examples and running tests, `--tags fts5 needs to be passed to the go command, to enable FTS5 support in some SQLite drivers like mattn/go-sqlite3.\n\n### Basic Example\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/rubiojr/hlx\"\n    _ \"github.com/mattn/go-sqlite3\"\n)\n\n// Define your document structure\ntype Document struct {\n    Id      string // Id field needs to be defined but not set\n    Title   string\n    Content string\n}\n\nfunc main() {\n    // Create a new index (in-memory database)\n    idx, err := hlx.NewIndex[Document](\":memory:\")\n    if err != nil {\n        panic(err)\n    }\n\n    // Insert documents\n    err = idx.Insert(\n        Document{\n            Title:   \"Hello World\",\n            Content: \"This is my first document\",\n        },\n        Document{\n            Title:   \"Second Post\",\n            Content: \"Another example document\",\n        },\n    )\n    if err != nil {\n        panic(err)\n    }\n\n    // Search documents\n    results, err := idx.Search(\"first OR example\")\n    if err != nil {\n        panic(err)\n    }\n\n    // Print results\n    for _, doc := range results {\n        fmt.Printf(\"Found document: %s - %s\\n\", doc.Title, doc.Content)\n    }\n}\n```\n\n### Initialization Examples\n\n#### Basic Initialization (In-Memory)\n```go\n// Create an in-memory index with default settings\nidx, err := hlx.NewIndex[Document](\":memory:\")\n```\n\n#### File-based Storage\n```go\n// Create a persistent database\nidx, err := hlx.NewIndex[Document](\"./documents.db\")\n```\n\n#### Custom Database Connection\n```go\nimport (\n    \"github.com/jmoiron/sqlx\"\n    _ \"github.com/mattn/go-sqlite3\"\n)\n\n// Use your own database connection\ndb, err := sqlx.Open(\"sqlite3\", \":memory:\")\nif err != nil {\n    panic(err)\n}\n\nidx, err := hlx.NewIndex[Document](\"\", hlx.WithDB(db))\n```\n\n#### Custom SQLite Pragmas\n```go\n// Use custom SQLite pragmas for performance tuning\ncustomPragmas := []string{\n    \"PRAGMA journal_mode=WAL\",\n    \"PRAGMA synchronous=NORMAL\",\n    \"PRAGMA cache_size=20000\",\n    \"PRAGMA temp_store=memory\",\n    \"PRAGMA busy_timeout=5000\",\n}\n\nidx, err := hlx.NewIndex[Document](\"./documents.db\", hlx.WithPragmas(customPragmas))\n```\n\n#### Combined Options\n```go\n// Combine multiple options\ndb, err := sqlx.Open(\"sqlite3\", \"./documents.db\")\nif err != nil {\n    panic(err)\n}\n\ncustomPragmas := []string{\n    \"PRAGMA journal_mode=WAL\",\n    \"PRAGMA cache_size=50000\",\n}\n\nidx, err := hlx.NewIndex[Document](\"\", \n    hlx.WithDB(db),\n    hlx.WithPragmas(customPragmas),\n)\n```\n\n#### Custom SQLite Driver\n```go\n// Use a specific SQLite driver (default is \"sqlite3\")\nidx, err := hlx.NewIndex[Document](\"./documents.db\", \n    hlx.WithSQLiteDriver(\"modernc.org/sqlite\"),\n)\n```\n\n### Search Syntax\n\nThe search syntax follows SQLite FTS5 query syntax. Here are some examples:\n\n```go\n// Simple word search\nresults, _ := idx.Search(\"hello\")\n\n// Phrase search\nresults, _ := idx.Search(`\"hello world\"`)\n\n// Boolean operators\nresults, _ := idx.Search(\"hello OR world\")\nresults, _ := idx.Search(\"hello AND world\")\n\n// Column-specific search\nresults, _ := idx.Search(\"title:hello\")\n\n// Complex queries\nresults, _ := idx.Search(`(title:\"hello world\") AND content:example`)\n\n// Exclude columns from search\nresults, _ := idx.Search(`- { title content } : \"hello\"`)\n```\n\n### Document Operations\n\n```go\n// Get document by ID\ndoc, err := idx.Get(\"some-id\")\n\n// Delete document by ID\nerr := idx.Delete(\"some-id\")\n\n// Get available fields\nfields := idx.Fields()\n```\n\n## Performance\n\nSee [performance.txt](/performance.txt).\n\n## Important Notes\n\n1. The document struct must have an `Id` field (case-sensitive)\n2. If no ID is provided when inserting a document, a UUID will be automatically generated\n3. All struct fields will be indexed and searchable\n4. Field names are case-insensitive in searches\n\n## License\n\nSee [LICENSE](/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubiojr%2Fhlx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubiojr%2Fhlx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubiojr%2Fhlx/lists"}