Construct the payload from the options
6166
private function getPayload()
    {
        $payloads = [
            'json' => Utils::findKey($this->options, 'json', false),
            'query' => Utils::findKey($this->options, 'query', false),
            'similar' => [
                'query' => [
                    'more_like_this' => [
                        'fields' => $this->fields,
                        'like_text' => $this->term,
                        'min_doc_freq' => 1,
                        'min_term_freq' => 1,
                        'analyzer' => "larasearch_search2"
                    ]
                ]
            ],
            'autocomplete' => [
                'query' => [
                    'multi_match' => [
                        'fields' => $this->fields,
                        'query' => $this->term,
                        'analyzer' => "larasearch_autocomplete_search"
                    ]
                ]
            ]
        ];

        // Find the correct payload based on the options
        $payload_key = array_intersect_key($this->options, $payloads);

        $operator = Utils::findKey($this->options, 'operator', 'and');

        if (count($payload_key) == 1)
        {
            $this->payload = array_merge($this->payload, $payloads[key($payload_key)]);
        } elseif (count($payload_key) == 0)
        {
            if ($this->term == '*')
            {
                $payload = ['match_all' => []];
            } else
            {
                $queries = [];

                foreach ($this->fields as $field)
                {
                    $qs = [];

                    $shared_options = [
                        'query' => $this->term,
                        'operator' => $operator,
                        'boost' => 1
                    ];

                    if ($field == '_all' || substr_compare($field, '.analyzed', -9, 9) === 0)
                    {
                        $qs = array_merge($qs, [
                                array_merge($shared_options, ['boost' => 10, 'analyzer' => "larasearch_search"]),
                                array_merge($shared_options, ['boost' => 10, 'analyzer' => "larasearch_search2"])
                            ]
                        );
                        if ($misspellings = Utils::findKey($this->options, 'misspellings', false))
                        {
                            $distance = 1;
                            $qs = array_merge($qs, [
                                    array_merge($shared_options, ['fuzziness' => $distance, 'max_expansions' => 3, 'analyzer' => "larasearch_search"]),
                                    array_merge($shared_options, ['fuzziness' => $distance, 'max_expansions' => 3, 'analyzer' => "larasearch_search2"])
                                ]
                            );

                        }
                    } elseif (substr_compare($field, '.exact', -6, 6) === 0)
                    {
                        $f = substr($field, 0, -6);
                        $queries[] = [
                            'match' => [
                                $f => array_merge($shared_options, ['analyzer' => 'keyword'])
                            ]
                        ];
                    } else
                    {
                        $analyzer = preg_match('/\.word_(start|middle|end)\z/', $field) ? "larasearch_word_search" : "larasearch_autocomplete_search";
                        $qs[] = array_merge($shared_options, ['analyzer' => $analyzer]);
                    }

                    $queries = array_merge($queries, array_map(function ($q) use ($field)
                    {
                        return ['match' => [$field => $q]];
                    }, $qs));
                }

                $payload = ['dis_max' => ['queries' => $queries]];
            }

            $this->payload['query'] = $payload;
        } else
        {
            // We have multiple query definitions, so abort
            throw new \InvalidArgumentException('Cannot use multiple query definitions.');
        }

        if ($load = Utils::findKey($this->options, 'load', false))
        {
            $this->payload['fields'] = is_array($load) ? $load : [];
        } elseif ($select = Utils::findKey($this->options, 'select', false))
        {
            $this->payload['fields'] = $select;
        }
    }
702985
def build_option_parser(parser):
    """"""
    parser.add_argument(
        "--os-data-processing-api-version",
        metavar="<data-processing-api-version>",
        default=utils.env(
            'OS_DATA_PROCESSING_API_VERSION',
            default=DEFAULT_DATA_PROCESSING_API_VERSION),
        help=("Data processing API version, default=" +
              DEFAULT_DATA_PROCESSING_API_VERSION +
              ' (Env: OS_DATA_PROCESSING_API_VERSION)'))
    parser.add_argument(
        "--os-data-processing-url",
        default=utils.env(
            "OS_DATA_PROCESSING_URL"),
        help=("Data processing API URL, "
              "(Env: OS_DATA_PROCESSING_API_URL)"))
    return parser
1349946
def decode_options(self, buffer):
        """"""
        fmt = b"!"
        options = {}

        log.debug("decode_options: buffer is: %s", repr(buffer))
        log.debug("size of buffer is %d bytes", len(buffer))
        if len(buffer) == 0:
            log.debug("size of buffer is zero, returning empty hash")
            return {}

        # Count the nulls in the buffer. Each one terminates a string.
        log.debug("about to iterate options buffer counting nulls")
        length = 0
        for i in range(len(buffer)):
            if ord(buffer[i:i+1]) == 0:
                log.debug("found a null at length %d", length)
                if length > 0:
                    fmt += b"%dsx" % length
                    length = -1
                else:
                    raise TftpException("Invalid options in buffer")
            length += 1

        log.debug("about to unpack, fmt is: %s", fmt)
        mystruct = struct.unpack(fmt, buffer)

        tftpassert(len(mystruct) % 2 == 0,
                   "packet with odd number of option/value pairs")

        for i in range(0, len(mystruct), 2):
            key = mystruct[i].decode('ascii')
            val = mystruct[i+1].decode('ascii')
            log.debug("setting option %s to %s", key, val)
            log.debug("types are %s and %s", type(key), type(val))
            options[key] = val

        return options
891374
def from_payload(self, payload):
        """"""
        self.session_id = payload[0]*256 + payload[1]
        self.index_id = payload[2]
        self.node_parameter = payload[3]
        self.seconds = payload[4]*256 + payload[5]
1002768
def construct_chunk(cls, chunk_type, payload, encoding='utf-8'):
    """"""
    if isinstance(payload, str):
      payload = payload.encode(encoding)
    elif not isinstance(payload, bytes):
      raise TypeError('cannot encode type: {}'.format(type(payload)))

    header = struct.pack(cls.HEADER_FMT, len(payload), chunk_type)
    return header + payload
1215213
def from_payload(self, payload):
        """"""
        self.status = SetNodeNameConfirmationStatus(payload[0])
        self.node_id = payload[1]
1098497
function payload( )
    {
        $doc = new DOMDocument( '1.0', 'utf-8' );
        $doc->name = "eZSOAP message";

        $root = $doc->createElementNS( ggSOAPRequest::ENV, ggSOAPRequest::ENV_PREFIX . ':Envelope' );

        $root->setAttribute( 'xmlns:' . ggSOAPRequest::XSI_PREFIX, ggSOAPRequest::SCHEMA_INSTANCE );
        $root->setAttribute( 'xmlns:' . ggSOAPRequest::XSD_PREFIX, ggSOAPRequest::SCHEMA_DATA );
        $root->setAttribute( 'xmlns:' . ggSOAPRequest::ENC_PREFIX, ggSOAPRequest::ENC );

        // add the body
        $body = $doc->createElement(  ggSOAPRequest::ENV_PREFIX . ':Body' );
        $root->appendChild( $body );

        // Check if it's a fault
        if ( $this->Value instanceof ggWebservicesFault || $this->Value instanceof eZSOAPFault )
        {
            $fault = $doc->createElement( ggSOAPRequest::ENV_PREFIX . ':Fault' );

            $faultCodeNode = $doc->createElement( "faultcode", $this->Value->faultCode() );
            $fault->appendChild( $faultCodeNode );

            $faultStringNode = $doc->createElement( "faultstring", $this->Value->faultString() );
            $fault->appendChild( $faultStringNode );

            $body->appendChild( $fault );
        }
        else
        {
            // add the response
            $responseName = $this->Name . "Response";
            $response = $doc->createElement( $responseName );
            $response->prefix = "resp";
            $response->setAttribute( 'xmlns:' . "resp", $this->ns );

            $return = $doc->createElement( "return" );
            $return->prefix = "resp";

            $value = ggSOAPRequest::encodeValue( $doc, "return", $this->Value );

            $response->appendChild( $value );

            $body->appendChild( $response );

        }

        $doc->appendChild( $root );

        return $doc->saveXML();
    }
90047
def payload_set(self, value):
        
        payload = saveJSON(value, pretty=False)
        super(APPDataMessage, self).payload_set(payload)
267816
def get_payload(self, *args, **kwargs):
        """"""
        if not kwargs:
            kwargs = self.default_params
        else:
            kwargs.update(self.default_params)
        for item in args:
            if isinstance(item, dict):
                kwargs.update(item)
        if hasattr(self, 'type_params'):
            kwargs.update(self.type_params(*args, **kwargs))
        return kwargs
1216059
def payload(self, value):
    """"""
    if not isinstance(value, rdfvalue.RDFValue):
      raise RuntimeError("Payload must be an RDFValue.")

    self.Set("args", value.SerializeToString())

    # pylint: disable=protected-access
    if value._age is not None:
      self.args_age = value._age
    # pylint: enable=protected-access

    self.args_rdf_name = value.__class__.__name__
670778
def payload_from_doc(req, doc, opts = {})
      if doc.is_a?(IO) || doc.is_a?(StringIO) || doc.is_a?(Tempfile) # attachments
        req[:header]['Content-Type'] = mime_for(req[:uri].path)
        doc
      elsif opts[:raw] || doc.nil?
        doc
      else
        MultiJson.encode(doc.respond_to?(:as_couch_json) ? doc.as_couch_json : doc)
      end
    end
294516
function _processOptions (options) {
        // Options parsing
        var
            name,
            maxLen;
        if (options instanceof Array) {
            options = gpf.Parameter.parse([{
                name: "port",
                type: "number",
                defaultValue: 80,
                prefix: "port"
            }, {
                name: "root",
                type: "string",
                defaultValue: ".",
                prefix: "root"
            }, {
                name: "chunkSize",
                type: "number",
                defaultValue: 65536,
                prefix: "chunk"
            }, gpf.Parameter.VERBOSE, gpf.Parameter.HELP], options);
        }
        // Server boot trace
        console.log("GPF " + gpf.version() + " web server");
        if (options.root === ".") {
            options.root = process.cwd();
        }
        if (options.verbose) {
            maxLen = 0;
            for (name in options) {
                if (options.hasOwnProperty(name)) {
                    if (name.length > maxLen) {
                        maxLen = name.length;
                    }
                }
            }
            ++maxLen;
            for (name in options) {
                if (options.hasOwnProperty(name)) {
                    console.log([
                        "\t",
                        name,
                        (new Array(maxLen - name.length + 1)).join(" "),
                        ": ",
                        options[name]
                    ].join(""));
                }
            }
        }
        return options;
    }
56743
function valuesToStrings(payload) {
	var stringifiedPayload = {};
	for (var key in payload) {
		if (payload.hasOwnProperty(key)) {
			stringifiedPayload[key] = payload[key].toString();
		}
	}
	return stringifiedPayload;
}
662167
def parse_payload(data, payload_fmt, *payload_names):
    
    payload = struct.unpack(payload_fmt, data)
    return dict(zip(payload_names, payload))
232936
def _create_payload(payload):
        
        blocks, remainder = divmod(len(payload), BLOCKSIZE)
        if remainder > 0:
            payload += (BLOCKSIZE - remainder) * NUL
        return payload
110699
def from_payload(self, payload):
        """"""
        self.session_id = payload[0]*256 + payload[1]
        self.originator = Originator(payload[2])
        self.priority = Priority(payload[3])

        len_node_ids = payload[41]
        if len_node_ids > 20:
            raise PyVLXException("command_send_request_wrong_node_length")
        self.node_ids = []
        for i in range(len_node_ids):
            self.node_ids.append(payload[42] + i)

        self.parameter = Parameter(payload[7:9])
1336526
def from_payload(self, payload):
        """"""
        self.status = ActivateSceneConfirmationStatus(payload[0])
        self.session_id = payload[1]*256 + payload[2]