sort query is overriding bool query while using elastic4s

83 Views Asked by At

Below is my code snippet for the query I am trying with elastic4s. Somehow the sortByFieldAsc is overriding the bool and because of that I am unable to get the correct result. I am trying to go through different examples but have not got any solution for it.

elastic4s version = 7.17.2

client execute {
    search("index").bool({ bool(Nil, Seq(should(matchQuery("something.outthere", s"*outthere*"))), Nil) })
      .from(0).size(100).sortByFieldAsc("something.date")
  }
1

There are 1 best solutions below

0
Pranjut On

I got a work around for this or probably that is the way to actually do it instead of trying it with sortyByFieldAsc. The solution was to sort the index itself. We can apply setting for the same in the elastic-search.