Skip to content

Commit

Permalink
Deprecate forceSource method/parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Philippus committed Aug 20, 2024
1 parent 7e520df commit 2b81528
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ class HighlightFieldBuilderFnTest extends AnyFunSuite with Matchers {
val highlight = HighlightField("text").boundaryMaxScan(20)
searches.HighlightFieldBuilderFn(highlight).string shouldBe """{"boundary_max_scan":20}"""
}
test("'forceSource' generates 'force_source' field.") {
test("'forceSource' has no effect.") {
val highlight = HighlightField("text").forceSource(true)
searches.HighlightFieldBuilderFn(highlight).string shouldBe """{"force_source":true}"""
searches.HighlightFieldBuilderFn(highlight).string shouldBe
"""{}""".stripMargin
}
test("'fragmentOffset' generates 'fragment_offset' field.") {
val highlight = HighlightField("text").fragmentOffset(100)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.sksamuel.elastic4s.requests.searches.queries.Query
case class HighlightField(field: String,
boundaryChars: Option[Array[Char]] = None,
boundaryMaxScan: Option[Int] = None,
@deprecated("This parameter has no effect", "8.15.0")
forceSource: Option[Boolean] = None,
fragmenter: Option[String] = None,
fragmentOffset: Option[Int] = None,
Expand Down Expand Up @@ -43,6 +44,7 @@ case class HighlightField(field: String,
def requireFieldMatch(requireFieldMatch: Boolean): HighlightField =
copy(requireFieldMatch = requireFieldMatch.some)

@deprecated("This method has no effect", "8.15.0")
def forceSource(forceSource: Boolean): HighlightField = copy(forceSource = forceSource.some)

def highlightFilter(highlightFilter: Boolean): HighlightField = copy(highlightFilter = highlightFilter.some)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ case class HighlightOptions(encoder: Option[String] = None,
boundaryScannerLocale: Option[String] = None,
fragmenter: Option[String] = None,
fragmentSize: Option[Int] = None,
@deprecated("This parameter has no effect", "8.15.0")
forceSource: Option[Boolean] = None,
highlighterType: Option[String] = None,
highlightFilter: Option[Boolean] = None,
Expand Down Expand Up @@ -43,6 +44,7 @@ case class HighlightOptions(encoder: Option[String] = None,
def fragmenter(fragmenter: String): HighlightOptions = copy(fragmenter = fragmenter.some)
def fragmentOffset(fragmentOffset: Int): HighlightOptions = copy(fragmentOffset = fragmentOffset.some)
def fragmentSize(fragmentSize: Int): HighlightOptions = copy(fragmentSize = fragmentSize.some)
@deprecated("This method has no effect", "8.15.0")
def forceSource(forceSource: Boolean): HighlightOptions = copy(forceSource = forceSource.some)

def highlighterType(highlighterType: String): HighlightOptions =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ object HighlightBuilderFn {
highlight.options.fragmentSize.foreach(builder.field("fragment_size", _))
highlight.options.numOfFragments.foreach(builder.field("number_of_fragments", _))
highlight.options.encoder.foreach(builder.field("encoder", _))
highlight.options.forceSource.foreach(builder.field("force_source", _))
highlight.options.highlighterType.foreach(builder.field("type", _))
highlight.options.highlightQuery.map(QueryBuilderFn.apply).foreach { highlight =>
builder.rawField("highlight_query", highlight)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ object HighlightFieldBuilderFn {
field.boundaryChars.foreach(chars => builder.field("boundary_chars", String.valueOf(chars)))
field.boundaryMaxScan.foreach(builder.field("boundary_max_scan", _))
field.encoder.foreach(builder.field("encoder", _))
field.forceSource.foreach(builder.field("force_source", _))
field.fragmenter.foreach(builder.field("fragmenter", _))
field.fragmentOffset.foreach(builder.field("fragment_offset", _))
field.fragmentSize.foreach(builder.field("fragment_size", _))
Expand Down

0 comments on commit 2b81528

Please sign in to comment.