Skip to content

Commit

Permalink
Adding missing value instead null
Browse files Browse the repository at this point in the history
Signed-off-by: Chaitanya Gohel <[email protected]>
  • Loading branch information
gashutos committed Nov 5, 2023
1 parent 29bdd91 commit a64da7b
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@
- match: { hits.hits.1._index: test_1 }
- match: { hits.hits.1._source.counter: 223372036854775800 }
- match: { hits.hits.1.sort.0: 223372036854775800 }
- match: { hits.hits.2._index: test_3 }
- match: { hits.hits.2._source.counter: 194.4 }

- do:
search:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,20 +344,30 @@
{"population": 184.4}
{"index":{}}
{"population": 194.4}
{"index":{}}
{"population": 144.4}
{"index":{}}
{"population": 174.4}
{"index":{}}
{"population": 164.4}
- do:
search:
index: test
rest_total_hits_as_int: true
body:
size: 1
size: 3
sort: [ { population: asc } ]
- match: { hits.total: 2 }
- length: { hits.hits: 1 }
- match: { hits.total: 5 }
- length: { hits.hits: 3 }
- match: { hits.hits.0._index: test }
- match: { hits.hits.0._source.population: 184.4 }
- match: { hits.hits.0._source.population: 144.4 }
- match: { hits.hits.1._index: test }
- match: { hits.hits.1._source.population: 164.4 }
- match: { hits.hits.2._index: test }
- match: { hits.hits.2._source.population: 174.4 }

# search_after with the sort
# search_after with the asc sort
- do:
search:
index: test
Expand All @@ -366,12 +376,26 @@
size: 1
sort: [ { population: asc } ]
search_after: [ 184.4 ]
- match: { hits.total: 2 }
- match: { hits.total: 5 }
- length: { hits.hits: 1 }
- match: { hits.hits.0._index: test }
- match: { hits.hits.0._source.population: 194.4 }

# search_after with the sort with missing
# search_after with the desc sort
- do:
search:
index: test
rest_total_hits_as_int: true
body:
size: 1
sort: [ { population: desc } ]
search_after: [ 164.4 ]
- match: { hits.total: 5 }
- length: { hits.hits: 1 }
- match: { hits.hits.0._index: test }
- match: { hits.hits.0._source.population: 164.4 }

# search_after with the asc sort with missing
- do:
bulk:
refresh: true
Expand All @@ -388,7 +412,22 @@
"sort": [ { "population": { "order": "asc", "missing": "_last" } } ]
search_after: [ 200 ] # making it out of min/max so only missing value hit is qualified

- match: { hits.total: 3 }
- match: { hits.total: 6 }
- length: { hits.hits: 1 }
- match: { hits.hits.0._index: test }
- match: { hits.hits.0._source.population: null }

# search_after with the desc sort with missing
- do:
search:
index: test
rest_total_hits_as_int: true
body:
"size": 5
"sort": [ { "population": { "order": "desc", "missing": "_last" } } ]
search_after: [ 100 ] # making it out of min/max so only missing value hit is qualified

- match: { hits.total: 6 }
- length: { hits.hits: 1 }
- match: { hits.hits.0._index: test }
- match: { hits.hits.0._source.population: null }
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public FieldComparator<?> newComparator(String fieldname, int numHits, boolean e
final double dMissingValue = (Double) missingObject(missingValue, reversed);
// NOTE: it's important to pass null as a missing value in the constructor so that
// the comparator doesn't check docsWithField since we replace missing values in select()
return new DoubleComparator(numHits, fieldname, null, reversed, enableSkipping && this.enableSkipping) {
return new DoubleComparator(numHits, fieldname, dMissingValue, reversed, enableSkipping && this.enableSkipping) {
@Override
public LeafFieldComparator getLeafComparator(LeafReaderContext context) throws IOException {
return new DoubleLeafComparator(context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public FieldComparator<?> newComparator(String fieldname, int numHits, boolean e
final float fMissingValue = (Float) missingObject(missingValue, reversed);
// NOTE: it's important to pass null as a missing value in the constructor so that
// the comparator doesn't check docsWithField since we replace missing values in select()
return new FloatComparator(numHits, fieldname, null, reversed, enableSkipping && this.enableSkipping) {
return new FloatComparator(numHits, fieldname, fMissingValue, reversed, enableSkipping && this.enableSkipping) {
@Override
public LeafFieldComparator getLeafComparator(LeafReaderContext context) throws IOException {
return new FloatLeafComparator(context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public FieldComparator<?> newComparator(String fieldname, int numHits, boolean e
final float fMissingValue = (Float) missingObject(missingValue, reversed);
// NOTE: it's important to pass null as a missing value in the constructor so that
// the comparator doesn't check docsWithField since we replace missing values in select()
return new HalfFloatComparator(numHits, fieldname, null, reversed, enableSkipping && this.enableSkipping) {
return new HalfFloatComparator(numHits, fieldname, fMissingValue, reversed, enableSkipping && this.enableSkipping) {
@Override
public LeafFieldComparator getLeafComparator(LeafReaderContext context) throws IOException {
return new HalfFloatLeafComparator(context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public FieldComparator<?> newComparator(String fieldname, int numHits, boolean e
final int iMissingValue = (Integer) missingObject(missingValue, reversed);
// NOTE: it's important to pass null as a missing value in the constructor so that
// the comparator doesn't check docsWithField since we replace missing values in select()
return new IntComparator(numHits, fieldname, null, reversed, enableSkipping && this.enableSkipping) {
return new IntComparator(numHits, fieldname, iMissingValue, reversed, enableSkipping && this.enableSkipping) {
@Override
public LeafFieldComparator getLeafComparator(LeafReaderContext context) throws IOException {
return new IntLeafComparator(context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public FieldComparator<?> newComparator(String fieldname, int numHits, boolean e
final long lMissingValue = (Long) missingObject(missingValue, reversed);
// NOTE: it's important to pass null as a missing value in the constructor so that
// the comparator doesn't check docsWithField since we replace missing values in select()
return new LongComparator(numHits, fieldname, null, reversed, enableSkipping && this.enableSkipping) {
return new LongComparator(numHits, fieldname, lMissingValue, reversed, enableSkipping && this.enableSkipping) {
@Override
public LeafFieldComparator getLeafComparator(LeafReaderContext context) throws IOException {
return new LongLeafComparator(context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public FieldComparator<?> newComparator(String fieldname, int numHits, boolean e
assert indexFieldData == null || fieldname.equals(indexFieldData.getFieldName());

final BigInteger ulMissingValue = (BigInteger) missingObject(missingValue, reversed);
return new UnsignedLongComparator(numHits, fieldname, null, reversed, enableSkipping && this.enableSkipping) {
return new UnsignedLongComparator(numHits, fieldname, ulMissingValue, reversed, enableSkipping && this.enableSkipping) {
@Override
public LeafFieldComparator getLeafComparator(LeafReaderContext context) throws IOException {
return new UnsignedLongLeafComparator(context) {
Expand Down

0 comments on commit a64da7b

Please sign in to comment.