Add full text search support using TSV indexes

This commit is contained in:
Vikram Rangnekar
2019-04-05 01:44:30 -04:00
parent 907ada9263
commit d1bf87e19c
8 changed files with 134 additions and 8 deletions

View File

@ -85,6 +85,7 @@ const (
OpHasKeyAll
OpIsNull
OpEqID
OpTsQuery
)
func (t ExpOp) String() string {
@ -139,6 +140,8 @@ func (t ExpOp) String() string {
v = "op-is-null"
case OpEqID:
v = "op-eq-id"
case OpTsQuery:
v = "op-ts-query"
}
return fmt.Sprintf("<%s>", v)
}
@ -341,6 +344,10 @@ func (com *Compiler) compileArgs(sel *Select, args []*Arg) error {
if sel.ID == int16(0) {
err = com.compileArgID(sel, args[i])
}
case "search":
if sel.ID == int16(0) {
err = com.compileArgSearch(sel, args[i])
}
case "where":
err = com.compileArgWhere(sel, args[i])
case "orderby", "order_by", "order":
@ -438,6 +445,25 @@ func (com *Compiler) compileArgID(sel *Select, arg *Arg) error {
return nil
}
func (com *Compiler) compileArgSearch(sel *Select, arg *Arg) error {
if sel.Where != nil && sel.Where.Op == OpTsQuery {
return nil
}
ex := &Exp{
Op: OpTsQuery,
Type: ValStr,
Val: arg.Val.Val,
}
if sel.Where != nil {
sel.Where = &Exp{Op: OpAnd, Children: []*Exp{ex, sel.Where}}
} else {
sel.Where = ex
}
return nil
}
func (com *Compiler) compileArgWhere(sel *Select, arg *Arg) error {
var err error