Skip to content

Commit

Permalink
Addressing more comments + adding tests
Browse files Browse the repository at this point in the history
Signed-off-by: Harsha Vamsi Kalluri <[email protected]>
  • Loading branch information
harshavamsi committed Dec 6, 2023
1 parent 9b4503e commit ad366c4
Show file tree
Hide file tree
Showing 2 changed files with 168 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
setup:
- skip:
features: [ "headers" ]
---
"search on number fields with doc_values enabled":
- do:
indices.create:
index: test-iodvq
body:
mappings:
dynamic: false
properties:
byte:
type: byte
index: false
doc_values: true
double:
type: double
index: false
doc_values: true
float:
type: float
index: false
doc_values: true
half_float:
type: half_float
index: false
doc_values: true
integer:
type: integer
index: false
doc_values: true
long:
type: long
index: false
doc_values: true
short:
type: short
index: false
doc_values: true
unsigned_long:
type: unsigned_long
index: false
doc_values: true


- do:
headers:
Content-Type: application/json
index:
index: "test-iodvq"
id: 1
body:
byte: 1
double: 1.0
float: 1.0
half_float: 1.0
integer: 1
long: 1
short: 1
unsigned_long: 1

- do:
headers:
Content-Type: application/json
index:
index: "test-iodvq"
id: 2
body:
byte: 2
double: 1.0
float: 1.0
half_float: 1.0
integer: 1
long: 1
short: 1
unsigned_long: 1


- do:
headers:
Content-Type: application/json
index:
index: "test-iodvq"
id: 3
body:
byte: 3
double: 1.0
float: 1.0
half_float: 1.0
integer: 1
long: 1
short: 1
unsigned_long: 1


- do:
indices.refresh: {}

- do:
search:
rest_total_hits_as_int: true
index: test-iodvq
body:
query:
term:
byte: 1

- match: {hits.total: 1}

- do:
search:
rest_total_hits_as_int: true
index: test-iodvq
body:
query:
term:
double: 1.0

- match: {hits.total: 3}

- do:
search:
rest_total_hits_as_int: true
index: test-iodvq
body:
query:
term:
float: 1.0

- match: {hits.total: 3}

- do:
search:
rest_total_hits_as_int: true
index: test-iodvq
body:
query:
term:
integer: 1

- match: {hits.total: 3}

- do:
search:
rest_total_hits_as_int: true
index: test-iodvq
body:
query:
term:
long: 1

- match: {hits.total: 3}


- do:
search:
rest_total_hits_as_int: true
index: test-iodvq
body:
query:
terms:
byte: [1, 2]

- match: {hits.total: 2}
Original file line number Diff line number Diff line change
Expand Up @@ -221,17 +221,17 @@ public Query termsQuery(String field, List<Object> values, boolean hasDocValues,
long points[] = new long[v.length];
for (int i = 0; i < values.size(); ++i) {
v[i] = parse(values.get(i), false);
points[i] = NumericUtils.floatToSortableInt(v[i]);
points[i] = HalfFloatPoint.halfFloatToSortableShort(v[i]);
}
if (isSearchable && hasDocValues) {
Query query = FloatPoint.newSetQuery(field, v);
Query query = HalfFloatPoint.newSetQuery(field, v);
Query dvQuery = SortedNumericDocValuesField.newSlowSetQuery(field, points);
return new IndexOrDocValuesQuery(query, dvQuery);
}
if (hasDocValues) {
return SortedNumericDocValuesField.newSlowSetQuery(field, points);
}
return FloatPoint.newSetQuery(field, v);
return HalfFloatPoint.newSetQuery(field, v);

}

Expand Down

0 comments on commit ad366c4

Please sign in to comment.