-
Notifications
You must be signed in to change notification settings - Fork 77
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
When using esb.sort().script(...) #78
Conversation
If esb.sort() is used without `field` parameter to use esb.sort().script(...), We can omit `field` parameter. This case is expression in the script section of [the document page](https://elastic-builder.js.org/docs/#sort).
Reviewer: @sudo-suhas |
Let's do the change in the following places to annotate the
Additionally, in the sort constructor, |
src/index.d.ts
Outdated
* Allows creating and configuring sort on specified field | ||
* but It is required .script() | ||
*/ | ||
export function sort(): Sort; |
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.
Just annotating the field
parameter for existing function and constructor declarations should be enough, no need to add the overriding function declaration.
src/core/sort.js
Outdated
@@ -31,7 +31,8 @@ const invalidUnitParam = invalidParam(ES_REF_URL, 'unit', UNIT_SET); | |||
* .query(esb.termQuery('user', 'kimchy')) | |||
* .sort(esb.sort('post_date', 'asc')) | |||
* | |||
* @param {string} field The field to sort on | |||
* @param {string=} field The field to sort on. | |||
* If `.script()` function is used, It will be omitted. |
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.
This could be reworded as
* If `.script()` function is used, It will be omitted. | |
* If a script is used to specify the sort order, `field` should be omitted. |
Could you please do these changes in the 3 places? I apologise for the redundancy, I am planning to do something about it sometime soon.
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 so easy. 😄
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.
I agree that it's easy but it's also easy to miss and not obvious that the same changes have to made in multiple places. Nevertheless, I appreciate your patience and cooperation.
Thank you @yoonhoGo for the PR! Changes merged in and released in |
Thank you @sudo-suhas. You're so very kind! |
If
esb.sort()
is used withoutfield
parameter to useesb.sort().script(...)
, We should omitfield
parameter.This case is expression in the script section of the document page.