Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blugelabs/bluge
indexing library for Go
https://github.com/blugelabs/bluge
Last synced: 11 days ago
JSON representation
indexing library for Go
- Host: GitHub
- URL: https://github.com/blugelabs/bluge
- Owner: blugelabs
- License: apache-2.0
- Created: 2020-08-30T02:20:00.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-11-15T16:37:09.000Z (over 1 year ago)
- Last Synced: 2024-02-21T21:35:19.760Z (4 months ago)
- Language: Go
- Size: 590 KB
- Stars: 1,799
- Watchers: 33
- Forks: 117
- Open Issues: 64
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Lists
- go-awesome - Bluge - 文本分词 (开源类库 / 搜索推荐)
- awesome-stars - blugelabs/bluge
- go-awesome - Bluge - Text segmentation (Open source library / Search Recommendations)
- awesome-search-tools - Bluge
README
# ![Bluge](docs/bluge.png) Bluge
[![PkgGoDev](https://pkg.go.dev/badge/github.com/blugelabs/bluge)](https://pkg.go.dev/github.com/blugelabs/bluge)
[![Tests](https://github.com/blugelabs/bluge/workflows/Tests/badge.svg?branch=master&event=push)](https://github.com/blugelabs/bluge/actions?query=workflow%3ATests+event%3Apush+branch%3Amaster)
[![Lint](https://github.com/blugelabs/bluge/workflows/Lint/badge.svg?branch=master&event=push)](https://github.com/blugelabs/bluge/actions?query=workflow%3ALint+event%3Apush+branch%3Amaster)modern text indexing in go - [blugelabs.com](https://www.blugelabs.com/)
## Features
* Supported field types:
* Text, Numeric, Date, Geo Point
* Supported query types:
* Term, Phrase, Match, Match Phrase, Prefix
* Conjunction, Disjunction, Boolean
* Numeric Range, Date Range
* BM25 Similarity/Scoring with pluggable interfaces
* Search result match highlighting
* Extendable Aggregations:
* Bucketing
* Terms
* Numeric Range
* Date Range
* Metrics
* Min/Max/Count/Sum
* Avg/Weighted Avg
* Cardinality Estimation ([HyperLogLog++](https://github.com/axiomhq/hyperloglog))
* Quantile Approximation ([T-Digest](https://github.com/caio/go-tdigest))## Indexing
```go
config := bluge.DefaultConfig(path)
writer, err := bluge.OpenWriter(config)
if err != nil {
log.Fatalf("error opening writer: %v", err)
}
defer writer.Close()doc := bluge.NewDocument("example").
AddField(bluge.NewTextField("name", "bluge"))err = writer.Update(doc.ID(), doc)
if err != nil {
log.Fatalf("error updating document: %v", err)
}
```## Querying
```go
reader, err := writer.Reader()
if err != nil {
log.Fatalf("error getting index reader: %v", err)
}
defer reader.Close()query := bluge.NewMatchQuery("bluge").SetField("name")
request := bluge.NewTopNSearch(10, query).
WithStandardAggregations()
documentMatchIterator, err := reader.Search(context.Background(), request)
if err != nil {
log.Fatalf("error executing search: %v", err)
}
match, err := documentMatchIterator.Next()
for err == nil && match != nil {
err = match.VisitStoredFields(func(field string, value []byte) bool {
if field == "_id" {
fmt.Printf("match: %s\n", string(value))
}
return true
})
if err != nil {
log.Fatalf("error loading stored fields: %v", err)
}
match, err = documentMatchIterator.Next()
}
if err != nil {
log.Fatalf("error iterator document matches: %v", err)
}
```## Repobeats
![Alt](https://repobeats.axiom.co/api/embed/0d7f8bc7927e15b07f1ae592eeff01811c5a2f80.svg "Repobeats analytics image")
## License
Apache License Version 2.0