Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,41 @@ class org.elasticsearch.script.Field {
boolean isEmpty()
List getValues()
def getValue(def)

org.elasticsearch.script.LongField asLongField()
long getLong(long)

org.elasticsearch.script.DoubleField asDoubleField()
double getDouble(double)

org.elasticsearch.script.BigIntegerField asBigIntegerField()
BigInteger getBigInteger(BigInteger)

org.elasticsearch.script.StringField asStringField()
String getString(String)

org.elasticsearch.script.DefField asDefField()
def getDef(def)
}

class org.elasticsearch.script.LongField {
long getLong(long)
}

class org.elasticsearch.script.DoubleField {
double getDouble(double)
}

class org.elasticsearch.script.BigIntegerField {
BigInteger getBigInteger(BigInteger)
}

class org.elasticsearch.script.StringField {
String getString(String)
}

class org.elasticsearch.script.DefField {
def getValue(def)
}

class org.elasticsearch.script.DocBasedScript {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,48 @@ setup:
body: {"dval": 5, "sval": "a"}
- do:
indices.refresh: {}
- do:
search:
rest_total_hits_as_int: true
index: test
body:
sort:
_script:
type: number
script:
source: "field('dval').asDoubleField().getValue(3)"
- match: { hits.total: 3 }
- match: { hits.hits.0._id: d2 }
- match: { hits.hits.1._id: d3 }
- match: { hits.hits.2._id: d1 }
- do:
search:
rest_total_hits_as_int: true
index: test
body:
sort:
_script:
type: number
script:
source: "field('dval').asDoubleField().getDouble(3)"
- match: { hits.total: 3 }
- match: { hits.hits.0._id: d2 }
- match: { hits.hits.1._id: d3 }
- match: { hits.hits.2._id: d1 }
- do:
search:
rest_total_hits_as_int: true
index: test
body:
sort:
_script:
type: number
script:
source: "field('dval').getDouble(3)"
- match: { hits.total: 3 }
- match: { hits.hits.0._id: d2 }
- match: { hits.hits.1._id: d3 }
- match: { hits.hits.2._id: d1 }
- do:
search:
rest_total_hits_as_int: true
Expand All @@ -48,6 +90,48 @@ setup:
- match: { hits.hits.0._id: d2 }
- match: { hits.hits.1._id: d3 }
- match: { hits.hits.2._id: d1 }
- do:
search:
rest_total_hits_as_int: true
index: test
body:
sort:
_script:
type: string
script:
source: "field('sval.keyword').asStringField().getValue('g')"
- match: { hits.total: 3 }
- match: { hits.hits.0._id: d3 }
- match: { hits.hits.1._id: d1 }
- match: { hits.hits.2._id: d2 }
- do:
search:
rest_total_hits_as_int: true
index: test
body:
sort:
_script:
type: string
script:
source: "field('sval.keyword').asStringField().getString('g')"
- match: { hits.total: 3 }
- match: { hits.hits.0._id: d3 }
- match: { hits.hits.1._id: d1 }
- match: { hits.hits.2._id: d2 }
- do:
search:
rest_total_hits_as_int: true
index: test
body:
sort:
_script:
type: string
script:
source: "field('sval.keyword').getString('g')"
- match: { hits.total: 3 }
- match: { hits.hits.0._id: d3 }
- match: { hits.hits.1._id: d1 }
- match: { hits.hits.2._id: d2 }
- do:
search:
rest_total_hits_as_int: true
Expand Down Expand Up @@ -92,6 +176,48 @@ setup:
body: {"dval": 5}
- do:
indices.refresh: {}
- do:
search:
rest_total_hits_as_int: true
index: test
body:
query:
script_score:
query: {match_all: {} }
script:
source: "field('dval').asDoubleField().getValue(3)"
- match: { hits.total: 3 }
- match: { hits.hits.0._id: d1 }
- match: { hits.hits.1._id: d3 }
- match: { hits.hits.2._id: d2 }
- do:
search:
rest_total_hits_as_int: true
index: test
body:
query:
script_score:
query: {match_all: {} }
script:
source: "field('dval').asDoubleField().getDouble(3)"
- match: { hits.total: 3 }
- match: { hits.hits.0._id: d1 }
- match: { hits.hits.1._id: d3 }
- match: { hits.hits.2._id: d2 }
- do:
search:
rest_total_hits_as_int: true
index: test
body:
query:
script_score:
query: {match_all: {} }
script:
source: "field('dval').getDouble(3)"
- match: { hits.total: 3 }
- match: { hits.hits.0._id: d1 }
- match: { hits.hits.1._id: d3 }
- match: { hits.hits.2._id: d2 }
- do:
search:
rest_total_hits_as_int: true
Expand Down Expand Up @@ -136,6 +262,29 @@ setup:
body: {"dval": 5, "sval": "a"}
- do:
indices.refresh: {}
- do:
search:
rest_total_hits_as_int: true
body:
query:
bool:
filter:
script:
script: "field('dval').asDoubleField().getValue(6) > 6"
- match: { hits.total: 1 }
- match: { hits.hits.0._id: d1 }
- do:
search:
rest_total_hits_as_int: true
body:
query:
bool:
filter:
script:
script: "field('dval').getDouble(6) > 6"
- match: { hits.total: 1 }
- match: { hits.hits.0._id: d1 }
- match: { hits.hits.0._id: d1 }
- do:
search:
rest_total_hits_as_int: true
Expand All @@ -147,6 +296,28 @@ setup:
script: "field('dval').getValue(6) > 6"
- match: { hits.total: 1 }
- match: { hits.hits.0._id: d1 }
- do:
search:
rest_total_hits_as_int: true
body:
query:
bool:
filter:
script:
script: "field('sval.keyword').asDefField().getValue('b') == 'a'"
- match: { hits.total: 1 }
- match: { hits.hits.0._id: d3 }
- do:
search:
rest_total_hits_as_int: true
body:
query:
bool:
filter:
script:
script: "field('sval.keyword').getDef('b') == 'a'"
- match: { hits.total: 1 }
- match: { hits.hits.0._id: d3 }
- do:
search:
rest_total_hits_as_int: true
Expand All @@ -158,3 +329,14 @@ setup:
script: "field('sval.keyword').getValue('b') == 'a'"
- match: { hits.total: 1 }
- match: { hits.hits.0._id: d3 }
- do:
search:
rest_total_hits_as_int: true
body:
query:
bool:
filter:
script:
script: "field('sval.keyword').getString('b') == 'a'"
- match: { hits.total: 1 }
- match: { hits.hits.0._id: d3 }
Loading