Skip to content
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

Sort/ script: Instance Member #77

Closed
seohyun0120 opened this issue Nov 19, 2018 · 3 comments
Closed

Sort/ script: Instance Member #77

seohyun0120 opened this issue Nov 19, 2018 · 3 comments

Comments

@seohyun0120
Copy link

seohyun0120 commented Nov 19, 2018

Hi! I found out some problem using esb.sort()

According to the document (https://elastic-builder.js.org/docs/#sort), it says that esb.sort needs field as essential and order as optional. It works fine for specific field. But there is a problem when I use script instance member.

esb.requestBodySearch().sort(
    esb.sort()
    .type('number')
    .script(
        esb.script('inline', "doc['field_name'].value * params.factor")
            .lang('painless')
            .params({ factor: 1.1 })
    )
    .order('asc')
)

I needed to custom my field value, so I used script instance member. But the third line gives me an error message, Expected 1-2 arguments, but got 0.

I think field type should be optional not essential.

new Sort(field: string, order: string?)

Or Am I missing something? Let me know.
Thank you
Reviewer: @sudo-suhas

@sudo-suhas
Copy link
Owner

Correct me if I wrong, from what I can tell, the resolution for this problem is to annotate the field option to the esb.sort method as optional. The issue is not with the actual code but the jsdoc and typings.

@seohyun0120
Copy link
Author

Great! I just checked the comments you left on pull-request.
Thank you for the reply!

@sudo-suhas
Copy link
Owner

For reference in the future, closed by #78.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants