コード例 #1
0
  public Filter getInnerFilter() throws IOException {
    if (filterParsed) {
      return innerFilter;
    } else {
      if (path == null) {
        throw new QueryParsingException(parseContext.index(), "[nested] requires 'path' field");
      }
      if (!filterFound) {
        throw new QueryParsingException(
            parseContext.index(), "[nested] requires either 'query' or 'filter' field");
      }

      setPathLevel();
      XContentParser old = parseContext.parser();
      try {
        XContentParser innerParser = XContentHelper.createParser(source);
        parseContext.parser(innerParser);
        innerFilter = parseContext.parseInnerFilter();
        filterParsed = true;
        return innerFilter;
      } finally {
        resetPathLevel();
        parseContext.parser(old);
      }
    }
  }
コード例 #2
0
 public void filter() throws IOException {
   if (path != null) {
     setPathLevel();
     try {
       innerFilter = parseContext.parseInnerFilter();
     } finally {
       resetPathLevel();
     }
     filterParsed = true;
   } else {
     source = XContentFactory.smileBuilder().copyCurrentStructure(parseContext.parser()).bytes();
   }
   filterFound = true;
 }