https://github.com/abbychau/hamfts
https://github.com/abbychau/hamfts
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/abbychau/hamfts
- Owner: abbychau
- Created: 2025-01-08T23:31:38.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-01-08T23:41:59.000Z (5 months ago)
- Last Synced: 2025-01-09T00:49:27.122Z (5 months ago)
- Language: Go
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Hamfts: Simple Full-Text Search Engine in Go
A lightweight implementation of an Elasticsearch-like search engine in Go, featuring inverted indexing for efficient text search capabilities.
## Features
- Document management with custom metadata
- Thread-safe operations
- Inverted index for fast full-text search
- Basic CRUD operations
- Custom document IDs and timestamps
- Metadata support for flexible document attributes## Installation
```bash
go get github.com/abbychau/hamfts
```## Quick Start
### Start the Server
```bash
go run main.go
```### Basic Operations
Add a document:
```bash
curl -X POST http://localhost:8080/documents -d '{
"id": "1",
"content": "The quick brown fox",
"metadata": {"category": "animals"}
}'
```Search documents:
```bash
curl -X POST http://localhost:8080/search -d '{
"query": "quick fox"
}'
```Get stats:
```bash
curl http://localhost:8080/stats
```## API Usage
### Creating and Adding Documents
```go
// Initialize a new index
idx := hamfts.NewIndex()// Create a new document with ID and content
doc := hamfts.NewDocument("1", "The quick brown fox jumps over the lazy dog")// Add custom metadata
doc.Metadata["category"] = "animals"// Add document to index
idx.AddDocument(doc)
```// ...existing code...
### Searching Documents