yaacov / tree-search-language

Tree Search Language (TSL) is a wonderful search langauge.
Apache License 2.0
60 stars 11 forks source link

tsl_mem with like keyword #7

Closed rawsyntax closed 5 years ago

rawsyntax commented 5 years ago

Should the tsl_mem binary work with like? For example:

./tsl_mem -i "author like '%joe%'"
2019/05/30 12:37:51 unexpected literal: $like

I see it listed as part of the grammar and used with other tsl binaries

yaacov commented 5 years ago

Hi, thanks for the issue :heart:

TSL language definition and implementations:

So TSL has two sets of string operators for "like":

1 - The SQL like: https://github.com/yaacov/tree-search-language/blob/master/pkg/tsl/consts.go#L33 https://github.com/yaacov/tree-search-language/blob/master/pkg/tsl/consts.go#L34

2 - The NoSQL regexp: RegexOp: https://github.com/yaacov/tree-search-language/blob/master/pkg/tsl/consts.go#L31

I did not implement all the operator in all the walkers ... , for example the SQL implementation did not implement the regexp operator, while the mongo one will skip the like.

tsl_mem

./tsl-mem example use the semantic walker to implement an in memory database: https://github.com/yaacov/tree-search-language/blob/master/cmd/tsl_mem/main.go#L31

Semantic Walker

When giving semantic meaning to the operators in semantic pkg ( https://godoc.org/github.com/yaacov/tree-search-language/pkg/walkers/semantics ) I only implemented the Regexp operator:

In the function that handle string operators: https://github.com/yaacov/tree-search-language/blob/master/pkg/walkers/semantics/walk.go#L192 I only implemented: RegExp: https://github.com/yaacov/tree-search-language/blob/master/pkg/walkers/semantics/walk.go#L212

And like falls into unexpected literal here: https://github.com/yaacov/tree-search-language/blob/master/pkg/walkers/semantics/walk.go#L226


P.S.

This will also happen in the mongo walker: https://github.com/yaacov/tree-search-language/blob/master/pkg/walkers/mongo/walk.go#L79 That only implement Regexp: https://github.com/yaacov/tree-search-language/blob/master/pkg/walkers/mongo/walk.go#L110

But not in the SQL walker :smile: : https://github.com/yaacov/tree-search-language/blob/master/pkg/walkers/sql/walk.go#L139

rawsyntax commented 5 years ago

@yaacov thanks! 🙏