1

Good day:

I'm currently have the following structure indexed school -> children...meaning for every school document, there's a list of children sub documents. Children is a nested list of objects inside School. My objective is to query the parent school.id=id and only return the sub-documents matching children.userId = userId while paginating the children size/from. I'm not sure how to accomplish this but, any help using NEST would be appreciated.

Thanks.

1 Answer 1

2

EDIT:

I didn't realize you only wanted to paginate the results from a single document. In that case you can use inner_hits which has it's own from and size parameters you can use.

Reference: inner_hits documentation

ORIGINAL ANSWER:

I don't think you can paginate directly on the inner object when you have a nested type. Instead you would want to index school and children in separate documents and use a join type to create a parent/child relationship between them. Then you could use a has_parent query to search for children and paginate on the children returned.

Reference:

How to create the mapping: Join Relationship

How to create the query: has_parent query

Sign up to request clarification or add additional context in comments.

2 Comments

Not totally understanding this. If I'm only doing paginating on sub documents on only ONE PARENT (never multiple parents..only one single parent) surely shouldn't this be possible with ES?
Sorry, didn't understand you only cared about one parent at a time. Updated my answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.