static {
   PARSER.declareField(
       constructorArg(), Script::parse, ScriptField.SCRIPT, ValueType.OBJECT_OR_STRING);
   PARSER.declareField(
       constructorArg(), p -> ScriptSortType.fromString(p.text()), TYPE_FIELD, ValueType.STRING);
   PARSER.declareString((b, v) -> b.order(SortOrder.fromString(v)), ORDER_FIELD);
   PARSER.declareString((b, v) -> b.sortMode(SortMode.fromString(v)), SORTMODE_FIELD);
   PARSER.declareString(ScriptSortBuilder::setNestedPath, NESTED_PATH_FIELD);
   PARSER.declareObject(
       ScriptSortBuilder::setNestedFilter, SortBuilder::parseNestedFilter, NESTED_FILTER_FIELD);
 }
Esempio n. 2
0
 static {
   PARSER =
       new ConstructingObjectParser<>(
           IndexResponse.class.getName(),
           args -> {
             // index uuid and shard id are unknown and can't be parsed back for now.
             ShardId shardId =
                 new ShardId(new Index((String) args[0], IndexMetaData.INDEX_UUID_NA_VALUE), -1);
             String type = (String) args[1];
             String id = (String) args[2];
             long version = (long) args[3];
             long seqNo =
                 (args[5] != null) ? (long) args[5] : SequenceNumbersService.UNASSIGNED_SEQ_NO;
             boolean created = (boolean) args[6];
             return new IndexResponse(shardId, type, id, seqNo, version, created);
           });
   DocWriteResponse.declareParserFields(PARSER);
   PARSER.declareBoolean(constructorArg(), new ParseField(CREATED));
 }
Esempio n. 3
0
 public static IndexResponse fromXContent(XContentParser parser) throws IOException {
   return PARSER.apply(parser, null);
 }
 /**
  * Creates a new {@link ScriptSortBuilder} from the query held by the {@link QueryParseContext} in
  * {@link org.elasticsearch.common.xcontent.XContent} format.
  *
  * @param context the input parse context. The state on the parser contained in this context will
  *     be changed as a side effect of this method call
  * @param elementName in some sort syntax variations the field name precedes the xContent object
  *     that specifies further parameters, e.g. in '{ "foo": { "order" : "asc"} }'. When parsing
  *     the inner object, the field name can be passed in via this argument
  */
 public static ScriptSortBuilder fromXContent(QueryParseContext context, String elementName)
     throws IOException {
   return PARSER.apply(context.parser(), context);
 }