Skip to content

Commit 8989868

Browse files
committed
fix sql specifications for es 7, 8 and 9
1 parent 1b9e8f7 commit 8989868

File tree

3 files changed

+141
-150
lines changed

3 files changed

+141
-150
lines changed

core/testkit/src/main/scala/app/softnetwork/elastic/client/ElasticClientSpec.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,14 @@ trait ElasticClientSpec extends AnyFlatSpecLike with ElasticDockerTestKit with M
191191
case other => fail(other.toString)
192192
}
193193

194-
pClient.search[Person]("select * from person_mapping where match(name, 'gum')") match {
194+
pClient.search[Person]("select * from person_mapping where match (name) against ('gum')") match {
195195
case r if r.size == 1 =>
196196
r.map(_.uuid) should contain only "A16"
197197
case other => fail(other.toString)
198198
}
199199

200200
pClient.search[Person](
201-
"select * from person_mapping where uuid <> 'A16' and match(name, 'gum')"
201+
"select * from person_mapping where uuid <> 'A16' and match (name) against ('gum')"
202202
) match {
203203
case r if r.isEmpty =>
204204
case other => fail(other.toString)
@@ -239,7 +239,7 @@ trait ElasticClientSpec extends AnyFlatSpecLike with ElasticDockerTestKit with M
239239

240240
"person_migration" should haveCount(3)
241241

242-
pClient.search[Person]("select * from person_migration where match(name, 'gum')") match {
242+
pClient.search[Person]("select * from person_migration where match (name) against ('gum')") match {
243243
case r if r.isEmpty =>
244244
case other => fail(other.toString)
245245
}
@@ -288,7 +288,7 @@ trait ElasticClientSpec extends AnyFlatSpecLike with ElasticDockerTestKit with M
288288
pClient.shouldUpdateMapping("person_migration", newMapping) shouldBe true
289289
pClient.updateMapping("person_migration", newMapping) shouldBe true
290290

291-
pClient.search[Person]("select * from person_migration where match(name, 'gum')") match {
291+
pClient.search[Person]("select * from person_migration where match (name) against ('gum')") match {
292292
case r if r.size == 1 =>
293293
r.map(_.uuid) should contain only "A16"
294294
case other => fail(other.toString)

sql/bridge/src/test/scala/app/softnetwork/elastic/sql/SQLCriteriaSpec.scala

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ package app.softnetwork.elastic.sql
22

33
import app.softnetwork.elastic.sql.bridge._
44
import com.sksamuel.elastic4s.ElasticApi.matchAllQuery
5-
import com.sksamuel.elastic4s.requests.searches.{SearchBodyBuilderFn, SearchRequest}
5+
import com.sksamuel.elastic4s.http.search.SearchBodyBuilderFn
6+
import com.sksamuel.elastic4s.searches.SearchRequest
67
import org.scalatest.flatspec.AnyFlatSpec
78
import org.scalatest.matchers.should.Matchers
89

@@ -146,7 +147,7 @@ class SQLCriteriaSpec extends AnyFlatSpec with Matchers {
146147
|"query":{
147148
| "bool":{"filter":[{"regexp" : {
148149
| "identifier" : {
149-
| "value" : ".*?un.*?"
150+
| "value" : ".*un.*"
150151
| }
151152
| }
152153
| }
@@ -160,7 +161,7 @@ class SQLCriteriaSpec extends AnyFlatSpec with Matchers {
160161
| "filter":[{"bool":{"must_not": [{
161162
| "regexp": {
162163
| "identifier": {
163-
| "value": ".*?un.*?"
164+
| "value": ".*un.*"
164165
| }
165166
| }
166167
| }]
@@ -781,10 +782,24 @@ class SQLCriteriaSpec extends AnyFlatSpec with Matchers {
781782
"""{
782783
| "query":{
783784
| "bool":{
784-
| "filter":[
785+
| "should":[
785786
| {
786787
| "match":{
787-
| "identifier":{
788+
| "identifier1":{
789+
| "query":"value"
790+
| }
791+
| }
792+
| },
793+
| {
794+
| "match":{
795+
| "identifier2":{
796+
| "query":"value"
797+
| }
798+
| }
799+
| },
800+
| {
801+
| "match":{
802+
| "identifier3":{
788803
| "query":"value"
789804
| }
790805
| }

0 commit comments

Comments
 (0)