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

Nested Query Format #130

Open
L-Luciano opened this issue Jan 15, 2020 · 0 comments
Open

Nested Query Format #130

L-Luciano opened this issue Jan 15, 2020 · 0 comments

Comments

@L-Luciano
Copy link

Mappings :
skills : type nested

Filter :
filter[where][and][0][skills.name]=BizTalk 2010&filter[where][and][0][skills.xp][gte]=15

2 nested will be create whereas I want 1 nested with 2 query.

Partial solution for range example:

// Additional handling for nested Objects
if (isNestedKey && !(inserted = this.insertNestedQuery(nestedSuperKey, rangeQuery, queryPath))) {
            rangeQuery = {
              nested: {
                path: nestedSuperKey,
                score_mode: 'max',
                query: rangeQuery
              }
            };
          }

          if (!inserted) {
            if (root) {
              queryPath.bool.must.push(rangeQuery);
            } else {
              queryPath.push(rangeQuery);
            }
          }
function insertNestedQuery(nestedSuperKey, query, queryPath) {
  const alreadyQueryNested = queryPath.filter(query => {
    if (query.nested) {
      return query.nested.path == nestedSuperKey;
    }
    return false;
  });

  if (alreadyQueryNested) {
    alreadyQueryNested[0].nested.query.bool.must.push(query);
    return true;
  }
  return false;
}
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

1 participant