All Projects → rekki → go-query

rekki / go-query

Licence: MIT license
⚡ Blazingly fast query engine

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to go-query

AdvancedSQL
The best Java query builder/SQL connector.
Stars: ✭ 23 (+43.75%)
Mutual labels:  query
craft-connect
Allows you to connect to external databases and perform db queries
Stars: ✭ 16 (+0%)
Mutual labels:  query
vaultaire
Query DSL and data access utilities for Corda developers.
Stars: ✭ 14 (-12.5%)
Mutual labels:  query
minecraft-server-status
PHP library to check Minecraft Servers Status
Stars: ✭ 36 (+125%)
Mutual labels:  query
stock-market-scraper
Scraps historical stock market data from Yahoo Finance (https://finance.yahoo.com/)
Stars: ✭ 110 (+587.5%)
Mutual labels:  query
Vendor-Threat-Triage-Lookup
Lookup file hashes, domain names and IP addresses using various vendors to assist with triaging potential threats.
Stars: ✭ 17 (+6.25%)
Mutual labels:  query
express-mquery
Expose mongoose query API through HTTP request.
Stars: ✭ 37 (+131.25%)
Mutual labels:  query
flame-explain
A PostgreSQL EXPLAIN ANALYZE visualizer with advanced quirk correction algorithms.
Stars: ✭ 30 (+87.5%)
Mutual labels:  query
Rhythm-CB-Scripts
Collection of scripts for use with Carbon Black Cb Response API
Stars: ✭ 14 (-12.5%)
Mutual labels:  query
Database-Web-API
Dynamically generate RESTful APIs from the contents of a database table. Provides JSON, XML, and HTML. Supports most popular databases
Stars: ✭ 37 (+131.25%)
Mutual labels:  query
m-custom-functions
This library contains created mostly pure M-functions without any other languages.
Stars: ✭ 24 (+50%)
Mutual labels:  query
SimplePHP
A small query builder project designed to assist daily routines and speed up the process of communicating with the database.
Stars: ✭ 14 (-12.5%)
Mutual labels:  query
json-sql-builder2
Level Up Your SQL-Queries
Stars: ✭ 59 (+268.75%)
Mutual labels:  query
python-qlient
A fast and modern graphql client designed with simplicity in mind.
Stars: ✭ 29 (+81.25%)
Mutual labels:  query
apex-query-builder
Convenient query builder for dynamic SOQL queries
Stars: ✭ 37 (+131.25%)
Mutual labels:  query
anapsid
An adaptive query processing engine for SPARQL endpoints.
Stars: ✭ 17 (+6.25%)
Mutual labels:  query
go-qs
A Go port of Rack's query string parser
Stars: ✭ 96 (+500%)
Mutual labels:  query
sqrs
🚌SQRS is a JavaScript library for implementing CQRS pattern.
Stars: ✭ 23 (+43.75%)
Mutual labels:  query
d3Tree
htmlwidget that binds d3js collapsible trees to R and Shiny to make an interactive search tool
Stars: ✭ 79 (+393.75%)
Mutual labels:  query
codecinfo
Detailed listing of multimedia codecs on an Android device
Stars: ✭ 33 (+106.25%)
Mutual labels:  query

go-query simple []int32 query library GitHub Actions Status codecov GoDoc

Blazingly fast query engine

Used to build and execute queries such as:

n := 10 // total docs in index

And(
        Term(n, "name:hello", []int32{4, 5}),
        Term(n, "name:world", []int32{4, 100}),
        Or(
                Term(n, "country:nl", []int32{20,30}),
                Term(n, "country:uk", []int32{4,30}),
        )
)
  • scoring: only idf score (for now)
  • supported queries: or, and, and_not, dis_max, constant, term
  • normalizers: space_between_digits, lowercase, trim, cleanup, etc
  • tokenizers: left edge, custom, charngram, unique, soundex etc
  • go-query-index: useful example of how to build more complex search engine with the library

query

Usually when you have inverted index you endup having something like:

data := []*Document{}
index := map[string][]int32{}
for docId, d := range document {
     for _, token := range tokenize(normalize(d.Name)) {
        index[token] = append(index[token],docId)
     }
}

then from documents like {hello world}, {hello}, {new york}, {new world} you get inverted index in the form of:

{
    "hello": [0,1],
    "world": [0,3],
    "new": [2,3],
    "york": [2]
}

anyway, if you want to read more on those check out the IR-book

This package helps you query indexes of this form, in fairly efficient way, keep in mind it expects the []int32 slices to be sorted. Example:

package main

import (
    "fmt"

    "github.com/rekki/go-query"
)

func main() {
    totalDocumentsInIndex := 10
    q := query.And(
        query.Or(
            query.Term(totalDocumentsInIndex, "a", []int32{1, 2, 8, 9}),
            query.Term(totalDocumentsInIndex, "b", []int32{3, 9, 8}),
        ),
        query.AndNot(
            query.Or(
                query.Term(totalDocumentsInIndex, "c", []int32{4, 5}),
                query.Term(totalDocumentsInIndex, "c", []int32{4, 100}),
            ),
            query.Or(
                query.Term(totalDocumentsInIndex, "d", []int32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}),
                query.Term(totalDocumentsInIndex, "e", []int32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}),
            ),
        ),
    )

    // q.String() is {{a OR b} AND {{d OR e} -({c OR x})}}

    for q.Next() != query.NO_MORE {
        did := q.GetDocId()
        score := q.Score()
        fmt.Printf("matching %d, score: %f\n", did, score)
    }
}

will print:

matching 1, score: 2.639057
matching 2, score: 2.639057
matching 3, score: 2.852632
matching 8, score: 2.639057
matching 9, score: 4.105394
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].