gosearch

command module
v0.0.0-...-d819428 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2021 License: MIT Imports: 7 Imported by: 0

README

GoSearch

Motivation

I just wanted to learn how to write a search engine from scratch without any prior experience.

Features

  • Index content
  • Search content
  • Index content REST API
  • Search content REST API
  • Delete content
  • Delete content REST API
  • Update content
  • Update content REST API

REST API

Index a new document:
curl -X POST http://localhost:8080/v1/insert -d "{\"content\": \"lorem ipsum\"}"

Search through all documents:
curl -X GET http://localhost:8080/v1/search?q=lorem

Golang API

First install the package via Go Mod:

go get github.com/micheleriva/gosearch

Then you can use its native Golang APIs to index and search for documents:

package main

import (
	"fmt"
	"github.com/micheleriva/gosearch"
)

func main() {
  gosearch.IndexDocument("Love is old, love is new, love is all, love is you")
  gosearch.IndexDocument("What is love? Baby don't hurt me, no more.")
  
  results := gosearch.Search("love")
  fmt.Println(results)
  // => ["Love is old, love is new, love is all, love is you", "What is love? Baby don't hurt me, no more."]
}

License

gosearch is licensed under the MIT license, but seriosuly, don't use it. Or do it at your own risk.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL