-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce 64-bit unsigned long field type #60050
Merged
mayya-sharipova
merged 18 commits into
elastic:master
from
mayya-sharipova:unsigned64bits_integer
Sep 23, 2020
Merged
Changes from 10 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
dffd748
Introduce 64-bit unsigned long field type
mayya-sharipova 7eb2d4a
Address feedback
mayya-sharipova 612b7da
Merge remote-tracking branch 'upstream/master' into unsigned64bits_in…
mayya-sharipova ada3422
Modifications after master merge
mayya-sharipova 7551cd6
Merge remote-tracking branch 'upstream/master' into unsigned64bits_in…
mayya-sharipova e903940
Rename methods
mayya-sharipova 9e057c0
Address Jim's feedback
mayya-sharipova ab54a23
Include unsigned_long docs into numeric type
mayya-sharipova 4de3bd0
Merge remote-tracking branch 'upstream/master' into unsigned64bits_in…
mayya-sharipova 2b567c9
Convert UnsignedLongFieldMapper to parametrized
mayya-sharipova 07470b5
Small edits in documentation
mayya-sharipova 17912bc
Address Julie's comment on documentation
mayya-sharipova b2eef4c
Add check that unsigned_long field type can't be sorted with other types
mayya-sharipova b315a0f
Merge remote-tracking branch 'upstream/master' into unsigned64bits_in…
mayya-sharipova 7652e66
Fix build and test failures
mayya-sharipova 0508e70
Merge remote-tracking branch 'upstream/master' into unsigned64bits_in…
mayya-sharipova 24cbe55
Rename the method for validating consistency of merge formats
mayya-sharipova cca6b30
Change unsigned_long mapper based on recent master changes
mayya-sharipova File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
[role="xpack"] | ||
[testenv="basic"] | ||
|
||
[[unsigned-long]] | ||
=== Unsigned long data type | ||
Unsigned long is a numeric field type that represents an unsigned 64-bit | ||
integer with a minimum value of 0 and a maximum value of +2^64^-1+ | ||
(from 0 to 18446744073709551615 inclusive). | ||
|
||
[source,console] | ||
-------------------------------------------------- | ||
PUT my_index | ||
{ | ||
"mappings": { | ||
"properties": { | ||
"my_counter": { | ||
"type": "unsigned_long" | ||
} | ||
} | ||
} | ||
} | ||
-------------------------------------------------- | ||
|
||
Unsigned long can be indexed in a numeric or string form, | ||
representing integer values in the range [0, 18446744073709551615]. | ||
They can't have a decimal part. | ||
|
||
[source,console] | ||
-------------------------------- | ||
POST /my_index/_bulk?refresh | ||
{"index":{"_id":1}} | ||
{"my_counter": 0} | ||
{"index":{"_id":2}} | ||
{"my_counter": 9223372036854775808} | ||
{"index":{"_id":3}} | ||
{"my_counter": 18446744073709551614} | ||
{"index":{"_id":4}} | ||
{"my_counter": 18446744073709551615} | ||
-------------------------------- | ||
//TEST[continued] | ||
|
||
Term queries accept any numbers in a numeric or string form. | ||
|
||
[source,console] | ||
-------------------------------- | ||
GET /my_index/_search | ||
{ | ||
"query": { | ||
"term" : { | ||
"my_counter" : 18446744073709551615 | ||
} | ||
} | ||
} | ||
-------------------------------- | ||
//TEST[continued] | ||
|
||
Range query terms can contain values with decimal parts. | ||
In this case {es} converts them to integer values: | ||
`gte` and `gt` terms are converted to the nearest integer up inclusive, | ||
and `lt` and `lte` ranges are converted to the nearest integer down inclusive. | ||
|
||
It is recommended to pass ranges as strings to ensure they are parsed | ||
without any loss of precision. | ||
|
||
[source,console] | ||
-------------------------------- | ||
GET /my_index/_search | ||
{ | ||
"query": { | ||
"range" : { | ||
"my_counter" : { | ||
"gte" : "9223372036854775808.5", | ||
"lte" : "18446744073709551615" | ||
} | ||
} | ||
} | ||
} | ||
-------------------------------- | ||
//TEST[continued] | ||
|
||
|
||
For queries with sort on an `unsigned_long` field, | ||
for a particular document {es} returns a sort value of the type `Long` | ||
if the value of this document is within the range of long values, | ||
or of the type `BigInteger` if the value exceeds this range. | ||
|
||
WARNING: Not all {es} clients can properly handle big integer values. | ||
|
||
[source,console] | ||
-------------------------------- | ||
GET /my_index/_search | ||
{ | ||
"query": { | ||
"match_all" : {} | ||
}, | ||
"sort" : {"my_counter" : "desc"} | ||
} | ||
-------------------------------- | ||
//TEST[continued] | ||
|
||
Similarly to sort values, script values of an `unsigned_long` field | ||
jtibshirani marked this conversation as resolved.
Show resolved
Hide resolved
|
||
produce `BigInteger` or `Long` values. The same values: `BigInteger` or | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd say |
||
`Long` are used for `terms` aggregation. | ||
|
||
==== Queries with mixed numeric types | ||
mayya-sharipova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Search queries across several numeric types one of which `unsigned_long` are | ||
supported, except queries with sort. Thus, a sort query across two indexes | ||
where the same field name has an `unsigned_long` type in one index, | ||
and `long` type in another, doesn't produce correct results and must | ||
be avoided. If there is a need for such kind of sorting, script based sorting | ||
can be used instead. | ||
|
||
Aggregations across several numeric types one of which is `unsigned_long` are | ||
supported. In this case, values are converted to the `double` type. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a bit scary to add as a warning ;). I would change {es} with something like
rest clients need to handle big integer values in json to support this field type correctly
or something along those lines ?