Skip to content

Commit

Permalink
Adding Unsigned Long Field Type (#2482)
Browse files Browse the repository at this point in the history
* local test / inital idea for unsigned long field type

* removed range - not actual type and added unsigned long string

* needed to update NumberFieldBuilderFn with string

* fixed compilation errors from typos like elastic4s somehow got changed to elastic5s

* typos, typos everywhere... double trippled checked with the tests
  • Loading branch information
cwgroppe committed Jul 27, 2021
1 parent 95d60fa commit 25997ff
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.sksamuel.elastic4s.api

import com.sksamuel.elastic4s.fields.{BinaryField, BooleanField, ByteField, CompletionField, DateField, DoubleField, FloatField, GeoPointField, GeoShapeField, HalfFloatField, IntegerField, IpField, JoinField, KeywordField, LongField, NestedField, ObjectField, ScaledFloatField, SearchAsYouTypeField, ShortField, TextField, WildcardField}
import com.sksamuel.elastic4s.fields.{BinaryField, BooleanField, ByteField, CompletionField, DateField, DoubleField, FloatField, GeoPointField, GeoShapeField, HalfFloatField, IntegerField, IpField, JoinField, KeywordField, LongField, NestedField, ObjectField, ScaledFloatField, SearchAsYouTypeField, ShortField, TextField, UnsignedLongField, WildcardField}
import com.sksamuel.elastic4s.requests.script.{Script, ScriptField}

trait TypesApi {
Expand All @@ -10,15 +10,16 @@ trait TypesApi {
def wildcardField(name: String): WildcardField = WildcardField(name)
def searchAsYouType(name: String): SearchAsYouTypeField = SearchAsYouTypeField(name)

def byteField(name: String) = ByteField(name)
def doubleField(name: String) = DoubleField(name)
def floatField(name: String) = FloatField(name)
def halfFloatField(name: String) = HalfFloatField(name)
def intField(name: String) = IntegerField(name)
def longField(name: String) = LongField(name)
def booleanField(name: String) = BooleanField(name)
def scaledFloatField(name: String) = ScaledFloatField(name)
def shortField(name: String) = ShortField(name)
def byteField(name: String) = ByteField(name)
def doubleField(name: String) = DoubleField(name)
def floatField(name: String) = FloatField(name)
def halfFloatField(name: String) = HalfFloatField(name)
def intField(name: String) = IntegerField(name)
def unsignedLongfield(name: String) = UnsignedLongField(name)
def longField(name: String) = LongField(name)
def booleanField(name: String) = BooleanField(name)
def scaledFloatField(name: String) = ScaledFloatField(name)
def shortField(name: String) = ShortField(name)

def dateField(name: String) = DateField(name)
def geopointField(name: String) = GeoPointField(name)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.sksamuel.elastic4s.fields

case class UnsignedLongField(name: String,
boost: Option[Double] = None,
coerce: Option[Boolean] = None,
copyTo: Seq[String] = Nil,
docValues: Option[Boolean] = None,
ignoreMalformed: Option[Boolean] = None,
index: Option[Boolean] = None,
store: Option[Boolean] = None,
nullValue: Option[Long] = None,
meta: Map[String, Any] = Map.empty) extends NumberField[Long] {
override def `type`: String = "unsigned_long"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.sksamuel.elastic4s.fields

case class UnsignedLongStringField(name: String,
boost: Option[Double] = None,
coerce: Option[Boolean] = None,
copyTo: Seq[String] = Nil,
docValues: Option[Boolean] = None,
ignoreMalformed: Option[Boolean] = None,
index: Option[Boolean] = None,
store: Option[Boolean] = None,
nullValue: Option[String] = None,
meta: Map[String, Any] = Map.empty) extends NumberField[String] {
override def `type`: String = "unsigned_long"
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ object NumberFieldBuilderFn {
case v: Int => builder.field("null_value", v)
case v: Byte => builder.field("null_value", v)
case v: Short => builder.field("null_value", v)
case v: String => builder.field("null_value", v)
}
field.store.foreach(builder.field("store", _))
field.coerce.foreach(builder.field("coerce", _))
Expand Down
4 changes: 4 additions & 0 deletions project/metals.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// DO NOT EDIT! This file is auto-generated.
// This file enables sbt-bloop to create bloop config files.

addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.4.3")

0 comments on commit 25997ff

Please sign in to comment.