Answers for "how to migrate from filterBuilder to higher version of elasticsearch"

0

how to migrate from filterBuilder to higher version of elasticsearch

// Code in 1.6
FilterBuilder filterBuilder = FilterBuilders.boolFilter()
  .should(
    FilterBuilders.boolFilter().must(
      QueryFilters.hostTeam(teamName),
      QueryFilters.hostGoals(scoredGoals, RangeModes.GTE),
      QueryFilters.guestGoals(scoredGoals, RangeModes.LT)
    ),
    FilterBuilders.boolFilter().must(
      QueryFilters.guestTeam(teamName),
      QueryFilters.guestGoals(scoredGoals, RangeModes.GTE),
      QueryFilters.hostGoals(scoredGoals, RangeModes.LT)
    )
);

// Code in 2.2
QueryBuilder filterBuilder = QueryBuilders.boolQuery()
  .should(
    QueryBuilders.boolQuery().must(QueryFilters.hostTeam(teamName))
      .must(QueryFilters.hostGoals(scoredGoals, RangeModes.GTE))
      .must(QueryFilters.guestGoals(scoredGoals, RangeModes.LT))
  )
  .should(
    QueryBuilders.boolQuery().must(QueryFilters.guestTeam(teamName))
      .must(QueryFilters.guestGoals(scoredGoals, RangeModes.GTE))
      .must(QueryFilters.hostGoals(scoredGoals, RangeModes.LT))
);
Posted by: Guest on September-04-2020

Code answers related to "how to migrate from filterBuilder to higher version of elasticsearch"

Browse Popular Code Answers by Language