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

Support for multi nested paths and filters in sorts #106

Open
mohak-cf opened this issue Dec 19, 2019 · 2 comments
Open

Support for multi nested paths and filters in sorts #106

mohak-cf opened this issue Dec 19, 2019 · 2 comments

Comments

@mohak-cf
Copy link

Elasticsearch provides a way to have multiple nested paths in a sort field, documentation example -
https://www.elastic.co/guide/en/elasticsearch/reference/6.8/search-request-sort.html#_nested_sorting_examples

ElasticBuilder only supports adding a path and a filter in the nested query for sort, i.e
nested(nested: { path: string, filter: Query }): this;
There should also be support for adding another nested type object.

@sudo-suhas
Copy link
Owner

There is no hard restriction against setting an object with another nested object. If you are using Typescript, you can add an ignore directive for the same(// @ts-ignore). I will incorporate this suggestion for the next package release.

@jzzfs
Copy link

jzzfs commented Nov 14, 2022

Thanks @sudo-suhas -- I didn't know you can pass props to the fns and they won't get dropped!

@mohak-cf & anyone who stumbles on this in the future -- here's a what I ended up going with:

sort("deeply.nested.numericField")
    .mode("min")
    .order("asc")
    .nested({
      path: "deeply",
      filter: termsQuery("deeply.fieldToFilter", ["a", "b", "c"]),
      // @ts-ignore
      nested: {
        path: "deeply.nested",
        filter: termQuery("deeply.nested.anotherFieldToFilter", "xyz")
      }
    });

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

3 participants