I'm using scala language and scylladb database using phantom-dsl library.
I want to get the data of students from scylladb on the bases of city by using method ,
override def getStudnetByCity(city: String): Future[List[Student]] = {
studentDB.Student
.select
.where(_.city eqs city)
.fetch()
}
The above code working fine.
Now what I want to get all the student from city JERSEY as well as NEW JERSEY and WESTERN NEW JERSEY by only searching JERSEY using the given code
override def getStudnetByCity(city: String): Future[List[Student]] = {
studentDB.Student
.select
.where(_.city like s"%$city%")
.fetch()
}
but getting error at like
Error: Cannot resolve symbol like
what I tried: I import library:
import com.outworkers.phantom.builder.syntax.CQLSyntax.Operators.like
but nothing happened and still getting the same error.
here is my build.sbt:
ThisBuild / scalaVersion := "2.13.1"
libraryDependencies ++= Seq(
"com.outworkers" %% "phantom-dsl" % "2.59.0"
)
Is phontom doesn't suppor like or is there another way to do so?
EDIT:
I wrote a well detailed step by step "solution". The problem is that the question was for ScyllaDB and my approach will only work for Cassandra due to ScyllaDB doesn't support SASI Index. Also SASI index in Cassandra was experimental, it will be deprecated in v5 and removed in v6.
@NadavHar'El answer is the right one for this case. I will just add an example of how to follow his suggestion using phantom.
OLD ANSWER: (Using an experimental feature from Cassandra that will be deprecated)
To be able to do that, phantom lets you add SASI Index support. Based on the code you provided, your table definition should be something like
As it says in the docs in the Modes section:
The next step you have to do is add the SASI support for the column you want to filter
The SASI index must exist.
In some of your app you will have something like
to be able to do that you have to add the correct dependency
and then you can do the following
backing to your initial question
phantom supports like operator?, the answer isYes. It is possible to do it. You should have in mind that you have to do some extra steps and evaluate the trade-offs between using one or other type of indexes. For further information about SASI Index, I've found this other posts in stackoverflow: