public function retrieveKeyValueElement(
        $element, $attribute, $value, $params = array()
    )
    {
        $this->element = (string)$element;
        $this->attribute = (string)$attribute;
        $this->value = (string)$value;
        // /v1/keyvalue is deprecated, use /v1/search with structured
        // $query = '<query xmlns="http://marklogic.com/appservices/search">
        //             <container-query>
        //               <element name="' . $this->element . '" ns="" />';
        // $query .= $this->attribute ?
        //     '<attribute name=' . $this->attribute . ' ns="" />' :
        //     '';
        // $query .= '<term-query>
        //                 <text>' . $this->value . '</text>
        //               </term-query>
        //             </container-query>
        //           </query>';

        try {
            // Only include attribute in final array if it is set
            $array_attr = (!empty($attribute)) ?
                array('attribute' => $this->attribute) : array();
            $params = array_merge(
                array('element' => $this->element, 'value' => $this->value),
                $array_attr, $this->getParams(), $params);
            $request = new RESTRequest('GET', 'keyvalue', $params);

            $params = array_merge(
                array('element' => $this->element, 'value' => $this->value),
                $array_attr, $this->getParams(), $params);
            // $params = array_merge(
            //     array('structuredQuery' => $query),
            //     $this->getParams(), $params
            // );
            $request = new RESTRequest('GET', 'keyvalue', $params);
            $response = $this->client->send($request);
            $results = new SearchResults($response->getBody());
            return $results;
        } catch(Exception $e) {
            echo $e->getMessage() . ' in ' . $e->getFile() .
            ' on line ' . $e->getLine() . PHP_EOL;
        }
    }