Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support last sort value and search after request #147

Merged
merged 3 commits into from
Apr 6, 2023

Conversation

markaya
Copy link
Contributor

@markaya markaya commented Apr 6, 2023

No description provided.

@@ -72,6 +72,18 @@ object ElasticRequest {
def getById(index: IndexName, id: DocumentId): GetByIdRequest =
GetById(index = index, id = id, refresh = None, routing = None)

def searchAfter(index: IndexName, query: ElasticQuery[_], searchAfter: Json): SearchRequest =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this below search.

@@ -382,10 +396,12 @@ object ElasticRequest {

val highlightsJson: Json = highlights.map(_.toJson).getOrElse(Obj())

val searchAfterJson: Json = searchAfter.map(sa => Obj("search_after" -> sa)).getOrElse(Obj())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use fold?

@@ -65,6 +67,8 @@ final class SearchResult private[elasticsearch] (private val hits: List[Item]) e
}

def items: UIO[List[Item]] = ZIO.succeed(hits)

def lastSortValue(): ZIO[Any, Nothing, Option[Json]] = ZIO.succeed(lastSort)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use UIO here. Also, it can be lazy val, right? Also, items can be lazy val.

@@ -404,6 +415,7 @@ object ElasticRequest {
from: Option[Int],
highlights: Option[Highlights],
routing: Option[Routing],
searchAfter: Option[Json],
size: Option[Int]
) extends SearchAndAggregateRequest { self =>
def from(value: Int): SearchAndAggregateRequest =
Copy link
Collaborator

@dbulaja98 dbulaja98 Apr 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 def highlights(value: Highlights): SearchAndAggregateRequest =
      self.copy(highlights = Some(value))

Please provide this method in sealed trait SearchAndAggregateRequest:
def highlights(value: Highlights): SearchAndAggregateRequest

@drmarjanovic drmarjanovic merged commit fe6fe08 into main Apr 6, 2023
@drmarjanovic drmarjanovic deleted the dsl-support-search-after-request branch April 6, 2023 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants