Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kadnan/fehrist
Document Indexing and Searching Library in Go
https://github.com/kadnan/fehrist
go golang indexing inverted-index
Last synced: about 1 month ago
JSON representation
Document Indexing and Searching Library in Go
- Host: GitHub
- URL: https://github.com/kadnan/fehrist
- Owner: kadnan
- License: mit
- Created: 2020-06-07T12:47:53.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-06-07T16:46:18.000Z (over 4 years ago)
- Last Synced: 2024-06-20T03:40:02.062Z (6 months ago)
- Topics: go, golang, indexing, inverted-index
- Language: Go
- Size: 18.6 KB
- Stars: 18
- Watchers: 6
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Fehrist
[![Build Status](https://api.travis-ci.org/kadnan/fehrist.svg)](https://travis-ci.org/kadnan/fehrist)_Fehrist_ is a pure Go library for indexing different types of documents. Currently it supports only CSV and JSON but flexible architecture gives you liberty to add more documents. Fehrist(فہرست) is an Urdu word for **Index**. Similar terminologies used in Arabic(فھرس) and Farsi(فہرست) as well.
Fehrist is based on [Inverted Index](https://en.wikipedia.org/wiki/Inverted_index) data structure for indexing purposes.
## Examples
### For indexing
```
import (
"fmt"
"os"
"strconv""github.com/kadnan/fehrist/fehrist"
)
func main() {
path, _ := os.Getwd()
//Indexing CSV Files
CSVDocument := &fehrist.CSV{IndexName: "local"}
for i := 1; i < 3; i++ {
fileName := path + "/" + strconv.Itoa(i) + ".csv"
fmt.Println("Indexing CSV data from the file,", fileName, ". Please wait...")indexCount, err := CSVDocument.Index(fileName)
if err != nil {
fmt.Println(err)
} else {
fmt.Println("Total Words indexed", indexCount)
}
}//Indexing JSON files
JSONDocument := &fehrist.JSON{IndexName: "local"}
for i := 1; i < 3; i++ {
fileName := path + "/" + strconv.Itoa(i) + ".json"
fmt.Println("Indexing CSV data from the file,", fileName, ". Please wait...")indexCount, err := JSONDocument.Index(fileName)
if err != nil {
fmt.Println(err)
} else {
fmt.Println("Total Words indexed", indexCount)
}
}
}
```### For Searching
```
/* Searching Documents */CSVDocument.Init()
result, _, err := CSVDocument.Search("siddiqi")
if err != nil {
fmt.Println(err)
}
fmt.Println("Printing the text present in CSV Document")
fmt.Println(result)
```
If you want to learn how this all work then visit the [blog post](http://blog.adnansiddiqi.me/fehrist-document-indexing-library-in-go/)