| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861 |
- package search
- import (
- "fmt"
- "testing"
- "time"
- . "git.wecise.com/wecise/odbserver/odb"
- "git.wecise.com/wecise/odbserver/odb/test"
- "gitee.com/wecisecode/util/logger"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
- )
- type BasicTests struct {
- Test *testing.T
- g *Gutil
- }
- func BasicTest(t *testing.T) {
- g := test.TestG()
- t.Run("InitG", func(t *testing.T) {
- test := &BasicTests{Test: t, g: g}
- test.InitG()
- })
- t.Run("Class", func(t *testing.T) {
- test := &BasicTests{Test: t, g: g}
- test.Class()
- })
- t.Run("Data", func(t *testing.T) {
- test := &BasicTests{Test: t, g: g}
- test.Data()
- })
- time.Sleep(time.Duration(2) * time.Second)
- t.Run("Valid", func(t *testing.T) {
- test := &BasicTests{Test: t, g: g}
- test.Valid()
- })
- t.Run("Int", func(t *testing.T) {
- test := &BasicTests{Test: t, g: g}
- test.Int()
- })
- t.Run("Bool", func(t *testing.T) {
- test := &BasicTests{Test: t, g: g}
- test.Bool()
- })
- t.Run("FullSearch", func(t *testing.T) {
- test := &BasicTests{Test: t, g: g}
- test.FullSearch()
- })
- t.Run("Prefix", func(t *testing.T) {
- test := &BasicTests{Test: t, g: g}
- test.Prefix()
- })
- t.Run("NotIn", func(t *testing.T) {
- test := &BasicTests{Test: t, g: g}
- test.NotIn()
- })
- /*t.Run("Rename", func(t *testing.T) {
- test := &BasicTests{Test: t, g: g}
- test.Rename()
- })*/
- t.Run("Float", func(t *testing.T) {
- test := &BasicTests{Test: t, g: g}
- test.Float()
- })
- t.Run("Double", func(t *testing.T) {
- test := &BasicTests{Test: t, g: g}
- test.Double()
- })
- t.Run("Date", func(t *testing.T) {
- test := &BasicTests{Test: t, g: g}
- test.Date()
- })
- t.Run("Timestamp", func(t *testing.T) {
- test := &BasicTests{Test: t, g: g}
- test.Timestamp()
- })
- }
- func (t *BasicTests) InitG() {
- require.NotNil(t.Test, t.g)
- // namespace test
- //t.g.Query(` create class if not exists /test() with namespace="test" `)
- //t.g.Query(` create edge type if not exists test.connect `)
- }
- func (t *BasicTests) Class() {
- _, _, err := t.g.Query(`
- create class if not exists /test/search (
-
- v_varchar varchar,
- v_text text,
- v_int int,
- v_bigint bigint,
- v_smalldouble double,
- v_double double,
- v_float float,
- v_bool bool,
- v_date date,
- v_timestamp timestamp,
-
- indexes(v_varchar, v_text, v_int, v_bigint, v_double, v_float, v_smalldouble, v_bool, v_date, v_timestamp),
- keys(v_varchar, v_text)
- ) with autosearch=true;`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- require.Nil(t.Test, err, fmt.Sprint(err))
- }
- func (t *BasicTests) Data() {
- var err error
- _, _, err = t.g.Query(`insert into /test/search (v_varchar, v_text, v_int, v_bigint, v_float, v_double, v_smalldouble, v_bool, v_date, v_timestamp) values ('*Abc*', 'hello word 2003 123-456-789 中华人民共和国是中国的唯一合法政府,台湾是中国一部分。 Mercury, Venus2,Earch%。Mars$Uranus CeresAndJupiterOrSaturn #Neptune Pluto_Charon"\""', 1, 1234567890123456789, 1.1, 1.1234567890123456, 1.123456, true, "2021-06-17","2021-06-17 08:07:06" )`)
- _, _, err = t.g.Query(`insert into /test/search (v_varchar, v_text, v_int, v_bigint, v_float, v_double, v_smalldouble, v_bool, v_date, v_timestamp) values ('ABCDEF', 'because in both case, Cassandra guarantees that these queries performance will be proportional to the amount of data returned. In particular, if no users are born in 1981, then the second query performance will not depend of the number of user profile stored in the database (not directly at least: due to secondary index implementation consideration, this query may still depend on the number of node in the cluster, which indirectly depends on the amount of data stored. Nevertheless, the number of nodes will always be multiple number of magnitude lower than the number of user profile stored). Of course, both query may return very large result set in practice, but the amount of data returned can always be controlled by adding a LIMIT.', 1, 1234567890123456789, 1.1, 1.1234567890123456, 1.123456, false, "2021-06-18", "2021-06-18 09:08:07" )`)
- _, _, err = t.g.Query(`insert into /test/search (v_varchar, v_text, v_int, v_bigint, v_float, v_double, v_smalldouble, v_bool, v_date, v_timestamp) values ('3', '{
- "id": "omdb-query-query",
- "bid": "omdb-query-query",
- "type": "json-update",
- "data": {
- "message": [
- {
- "graph": {
- "nodes": [
- {
- "_icon": "app",
- "class": "/matrix/entity/app",
- "id": "app:demoapp3",
- "name": "app:demoapp3",
- "status": 5
- },
- {
- "class": "/matrix/entity/pod",
- "id": "pod:web-demo-f6dsp"
- },
- {
- "_icon": "mysql",
- "class": "/matrix/entity/mysql",
- "id": "mysql:demodb",
- "name": "mysql:demodb",
- "status": 0
- },
- {
- "_icon": "biz",
- "class": "/matrix/entity/biz",
- "id": "biz:开发测试",
- "name": "biz:开发测试",
- "status": 4
- },
- {
- "_icon": "linux",
- "class": "/matrix/entity/linux",
- "id": "linux:node2",
- "name": "linux:node2",
- "status": 0
- },
- {
- "_icon": "mysql",
- "class": "/matrix/entity/mysql",
- "id": "mysql:appdb",
- "name": "mysql:appdb",
- "status": 0
- },
- {
- "_icon": "app",
- "class": "/matrix/entity/app",
- "id": "app:demoapp2",
- "name": "app:demoapp2",
- "status": 0
- },
- {
- "_icon": "app",
- "class": "/matrix/entity/app",
- "id": "app:tomcat-app3",
- "name": "app:tomcat-app3",
- "status": 5
- },
- {
- "_icon": "linux",
- "class": "/matrix/entity/linux",
- "id": "linux:node1",
- "name": "linux:node1",
- "status": 0
- },
- {
- "_icon": "pod",
- "class": "/matrix/entity/pod",
- "id": "pod:tomcat-pod1",
- "name": "pod:tomcat-pod1",
- "status": 4
- },
- {
- "_icon": "linux",
- "class": "/matrix/entity/linux",
- "id": "linux:node4",
- "name": "linux:node4",
- "status": 0
- },
- {
- "_icon": "app",
- "class": "/matrix/entity/app",
- "id": "app:demoapp1",
- "name": "app:demoapp1",
- "status": 0
- },
- {
- "_icon": "pod",
- "class": "/matrix/entity/pod",
- "id": "pod:mysql-demo-pod1",
- "name": "pod:mysql-demo-pod1",
- "status": 4
- },
- {
- "_icon": "pod",
- "class": "/matrix/entity/pod",
- "id": "pod:tomcat-pod2",
- "name": "pod:tomcat-pod2",
- "status": 4
- },
- {
- "class": "/matrix/entity/pod",
- "id": "pod:tomcat-pod3"
- },
- {
- "_icon": "app",
- "class": "/matrix/entity/app",
- "id": "app:tomcat-app1",
- "name": "app:tomcat-app1",
- "status": 0
- },
- {
- "_icon": "app",
- "class": "/matrix/entity/app",
- "id": "app:tomcat-app2",
- "name": "app:tomcat-app2",
- "status": 0
- },
- {
- "class": "/matrix/entity/pod",
- "id": "pod:web-demo-j6qxj"
- },
- {
- "class": "/matrix/entity/pod",
- "id": "pod:web-demo-9rfxj"
- },
- {
- "_icon": "biz",
- "class": "/matrix/entity/biz",
- "id": "biz:数字国网",
- "name": "biz:数字国网",
- "status": 4
- }
- ],
- "edges": [
- {
- "attrs": {},
- "class": "connect",
- "id": "app:demoapp1-mysql:demodb",
- "source": "app:demoapp1",
- "target": "mysql:demodb"
- },
- {
- "attrs": {},
- "class": "contain",
- "id": "biz:开发测试-app:demoapp2",
- "source": "biz:开发测试",
- "target": "app:demoapp2"
- },
- {
- "attrs": {},
- "class": "runon",
- "id": "mysql:appdb-linux:node4",
- "source": "mysql:appdb",
- "target": "linux:node4"
- },
- {
- "attrs": {},
- "class": "runon",
- "id": "mysql:demodb-pod:mysql",
- "source": "mysql:demodb",
- "target": "pod:mysql"
- },
- {
- "attrs": {},
- "class": "runon",
- "id": "app:tomcat-app2",
- "source": "app:tomcat",
- "target": "app2"
- },
- {
- "attrs": {},
- "class": "runon",
- "id": "pod:tomcat-pod2",
- "source": "pod:tomcat",
- "target": "pod2"
- },
- {
- "attrs": {},
- "class": "runon",
- "id": "app:demoapp1-pod:web",
- "source": "app:demoapp1",
- "target": "pod:web"
- },
- {
- "attrs": {},
- "class": "runon",
- "id": "pod:mysql-demo",
- "source": "pod:mysql",
- "target": "demo"
- },
- {
- "attrs": {},
- "class": "runon",
- "id": "app:demoapp2-pod:web",
- "source": "app:demoapp2",
- "target": "pod:web"
- },
- {
- "attrs": {},
- "class": "connect",
- "id": "app:demoapp3-mysql:demodb",
- "source": "app:demoapp3",
- "target": "mysql:demodb"
- },
- {
- "attrs": {},
- "class": "runon",
- "id": "app:demoapp3-pod:web",
- "source": "app:demoapp3",
- "target": "pod:web"
- },
- {
- "attrs": {
- "floatp": 3.4,
- "intp": 1
- },
- "class": "contain",
- "id": "biz:数字国网-app:tomcat",
- "source": "biz:数字国网",
- "target": "app:tomcat"
- },
- {
- "attrs": {},
- "class": "connect",
- "id": "app:tomcat-app3",
- "source": "app:tomcat",
- "target": "app3"
- },
- {
- "attrs": {},
- "class": "contain",
- "id": "biz:开发测试-app:demoapp3",
- "source": "biz:开发测试",
- "target": "app:demoapp3"
- },
- {
- "attrs": {},
- "class": "contain",
- "id": "biz:开发测试-app:demoapp1",
- "source": "biz:开发测试",
- "target": "app:demoapp1"
- },
- {
- "attrs": {},
- "class": "runon",
- "id": "pod:tomcat-pod1",
- "source": "pod:tomcat",
- "target": "pod1"
- },
- {
- "attrs": {},
- "class": "connect",
- "id": "app:tomcat-app1",
- "source": "app:tomcat",
- "target": "app1"
- },
- {
- "attrs": {},
- "class": "connect",
- "id": "app:demoapp2-mysql:demodb",
- "source": "app:demoapp2",
- "target": "mysql:demodb"
- }
- ],
- "paths": null,
- "diff": null,
- "pathtags": null
- }
- }
- ],
- "meta": {
- "type": "graph"
- },
- "status": "ok"
- }
- }', 1, 1234567890123456789, 1.1, 1.1234567890123456, 1.123456, true, "2021-06-19", "2021-06-18 10:09:08" )`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- require.Nil(t.Test, err, fmt.Sprint(err))
- }
- func (t *BasicTests) Valid() {
- rtn, _, err := t.g.Search(`#/test/search`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 3, len(rtn), "they should be equal")
- for _, row := range rtn {
- switch row["v_varchar"].(string) {
- case "*Abc*":
- assert.Equal(t.Test, `hello word 2003 123-456-789 中华人民共和国是中国的唯一合法政府,台湾是中国一部分。 Mercury, Venus2,Earch%。Mars$Uranus CeresAndJupiterOrSaturn #Neptune Pluto_Charon"\""`, row["v_text"].(string), "they should be equal")
- }
- }
- }
- rtn, _, err = t.g.Search(` #/test/search | v_varchar=='*Abc*'`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 1, len(rtn), "they should be equal")
- }
- rtn, _, err = t.g.Search(` #/test/search | v_varchar='*ABC*'`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 1, len(rtn), "they should be equal")
- }
- rtn, _, err = t.g.Search(` #/test/search | v_text='Cassan*'`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 1, len(rtn), "they should be equal")
- }
- rtn, _, err = t.g.Search(`#id='1986187421140317314'`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 1, len(rtn), "they should be equal")
- }
- rtn, _, err = t.g.Search(`#/test/ | id='1986187421140317314'`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 1, len(rtn), "they should be equal")
- }
- }
- func (t *BasicTests) Int() {
- var err error
- var rtn []map[string]interface{}
- rtn, _, err = t.g.Search(`#/test/search | v_int = 1`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 3, len(rtn), fmt.Sprintf("not find v_int = %v", "1"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_int > 0`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 3, len(rtn), fmt.Sprintf("not find v_int > %v", "0"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_int < 2`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 3, len(rtn), fmt.Sprintf("not find v_int < %v", "2"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_int >= 1`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 3, len(rtn), fmt.Sprintf("not find v_int >= %v", "1"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_int <= 1`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 3, len(rtn), fmt.Sprintf("not find v_int <= %v", "1"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_int >= 1.1`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 3, len(rtn), fmt.Sprintf("not find v_int >= %v", "1.1"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_int > 1`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 0, len(rtn), fmt.Sprintf("not find v_int > %v", "1"))
- }
- }
- func (t *BasicTests) Bool() {
- var err error
- var rtn []map[string]interface{}
- rtn, _, err = t.g.Search(`#/test/search | v_bool = true`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 2, len(rtn), fmt.Sprintf("not find v_bool = %v", "true"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_bool = false`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 1, len(rtn), fmt.Sprintf("not find v_bool = %v", "false"))
- }
- }
- func (t *BasicTests) Float() {
- var err error
- var rtn []map[string]interface{}
- rtn, _, err = t.g.Search(`#/test/search | v_float >= 1.1`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 3, len(rtn), fmt.Sprintf("not find v_float >= %v", "1.1"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_float > 1`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 3, len(rtn), fmt.Sprintf("not find v_float > %v", "1"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_float = 1.1`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 3, len(rtn), fmt.Sprintf("not find v_float = %v", "1.1"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_float < 2`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 3, len(rtn), fmt.Sprintf("not find v_float < %v", "2"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_float <= 1.1`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 3, len(rtn), fmt.Sprintf("not find v_float <= %v", "1.1"))
- }
- }
- func (t *BasicTests) Date() {
- var err error
- var rtn []map[string]interface{}
- rtn, _, err = t.g.Search(`#/test/search | v_date = '2021-06-17'`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 1, len(rtn), fmt.Sprintf("not find v_date = %v", "2021-06-17"))
- }
- }
- func (t *BasicTests) Timestamp() {
- var err error
- var rtn []map[string]interface{}
- rtn, _, err = t.g.Search(`#/test/search | v_timestamp = '2021-06-17 08:07:06'`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 1, len(rtn), fmt.Sprintf("not find v_timestamp = %v", "2021-06-17 08-07-06"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_timestamp = '2021-06-17 08:07'`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 1, len(rtn), fmt.Sprintf("not find v_timestamp = %v", "2021-06-17 08:07"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_timestamp = '2021-06-17 08'`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 1, len(rtn), fmt.Sprintf("not find v_timestamp = %v", "2021-06-17 08"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_timestamp = '2021-06-17'`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 1, len(rtn), fmt.Sprintf("not find v_timestamp = %v", "2021-06-17"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_timestamp = '2021-06'`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 3, len(rtn), fmt.Sprintf("not find v_timestamp = %v", "2021-06"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_timestamp > 2021-06-17 08`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 3, len(rtn), fmt.Sprintf("not find v_timestamp > %v", "2021-06-17 08"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_timestamp < 2021-06-18`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 1, len(rtn), fmt.Sprintf("not find v_timestamp < %v", "2021-06-18"))
- }
- }
- func (t *BasicTests) Double() {
- var err error
- var rtn []map[string]interface{}
- rtn, _, err = t.g.Search(`#/test/search | v_double >= 1.1234567890123456`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 3, len(rtn), fmt.Sprintf("not find v_double >= %v", "1.1234567890123456"))
- }
- //??????
- rtn, _, err = t.g.Search(`#/test/search | v_smalldouble >= 1.123456`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 3, len(rtn), fmt.Sprintf("not find , v_smalldouble >= %v", "1.123456"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_double > 1`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 3, len(rtn), fmt.Sprintf("not find v_double > %v", "1"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_double = 1.1234567890123456`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 3, len(rtn), fmt.Sprintf("not find v_double = %v", "1.1234567890123456"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_double < 2`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 3, len(rtn), fmt.Sprintf("not find v_double < %v", "2"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_double <= 1.1234567890123456`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 3, len(rtn), fmt.Sprintf("not find v_double <= %v", "1.1234567890123456"))
- }
- }
- func (t *BasicTests) NotIn() {
- /*var err error
- var rtn []map[string]interface{}
- rtn,_,err = t.g.Search(`#/test/search | v_varchar not in('2', '3')`)
- if err !=nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 1, len(rtn), fmt.Sprintf("not find %v", "hello"))
- }*/
- }
- func (t *BasicTests) Prefix() {
- var err error
- var rtn []map[string]interface{}
- rtn, _, err = t.g.Search(`#/test/search | v_text='hell*'`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 1, len(rtn), fmt.Sprintf("not find %v", "hello"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_text='*20*'`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 1, len(rtn), fmt.Sprintf("not find %v", "2003"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_text='*123-456*'`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 1, len(rtn), fmt.Sprintf("not find %v", "123-456-789"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_text='*中*'`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 1, len(rtn), fmt.Sprintf("not find %v", "中国"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_text='*magni*'`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 1, len(rtn), fmt.Sprintf("not find %v", "magnitude"))
- }
- }
- func (t *BasicTests) FullSearch() {
- var err error
- var rtn []map[string]interface{}
- rtn, _, err = t.g.Search(`#/test/search | v_text='hello'`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 1, len(rtn), fmt.Sprintf("not find %v", "hello"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_text='2003'`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 1, len(rtn), fmt.Sprintf("not find %v", "2003"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_text='123-456-789'`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 1, len(rtn), fmt.Sprintf("not find %v", "123-456-789"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_text='中国'`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 1, len(rtn), fmt.Sprintf("not find %v", "中国"))
- }
- rtn, _, err = t.g.Search(`#/test/search | v_text='magnitude'`)
- if err != nil {
- logger.Errorf("%v", err)
- }
- if assert.Nil(t.Test, err) {
- assert.Equal(t.Test, 1, len(rtn), fmt.Sprintf("not find %v", "magnitude"))
- }
- }
|