MarkLogic Server 11.0 Product Documentation
POST /v1/config/query/(default|{name})/{child-element}

Summary

Add options to existing named query options, or create new named query options if {name} does not already exist.

URL Parameters
format? You can use this parameter as a fallback to the request Content-type header. The Content-type header takes precedence over format in most cases; for details, see Controlling Input and Output Content Type in the REST Application Developer's Guide. Accepted values: json or xml.
Request Headers
Content-Type The MIME type of the data in the request body. Accepted values: application/json or application/xml.

Response

Upon success, MarkLogic Server returns status 201 (Created) or 204 (Updated).

If the payload is invalid or applying the payload results in invalid query options, MarkLogic Server responds with status 400 (Bad Request) by default. Options validation can be disabled. For details, see see the validate-options in Instance Configuration Properties in the REST Application Developer's Guide.

Required Privileges

This operation requires the rest-admin role, or the following privileges:

http://marklogic.com/xdmp/privileges/rest-admin

http://marklogic.com/xdmp/privileges/rest-writer

http://marklogic.com/xdmp/privileges/rest-reader

Usage Notes

The POST body must be a valid search:options node, expressed in either XML or JSON, depending upon the request Content-Type header or format parameter.

For a summary of available options, see PUT /v1/config/query/(default|{name}). For details see Appendix: Query Options Reference in the Search Developer's Guide.

Multiple option elements (settings) may be included in the options node if {child-element} is an element that can occur multiple times in query options. For example, multiple search constraints (<constraint/>) may be set in a single request. However, all options in the payload must be of the same type.

If no query options are installed under {name}, they are created. If the named query options exist, the options in the POST body are appended. If options validation is enabled (the default) and adding the new options would result in invalid query options, the query options remain unchanged, and a 400 status is returned. Options validation can be disabled. For details, see validate-options in Instance Configuration Properties in the REST Application Developer's Guide.

If {name} is default, the default search options are modified.

For more details, see Configuring Query Options in the REST Application Developer's Guide.

Example

$ cat added-constraint.xml
<options xmlns="http://marklogic.com/appservices/search">
  <constraint name="title">
    <word>
      <element ns="" name="TITLE" />
    </word>
  </constraint>
</options>

$ curl --anyauth --user user:password -i -X POST -d@"added-constraint.xml" \
    -H "Content-type: application/xml" \
    http://localhost:8000/v1/config/query/my-options/constraint

==> The "title" constraint is added to the "my-options" query options. If
    the query options already contain other <constraint/> elements, they 
    are unchanged.  MarkLogic Server returns the following headers:

HTTP/1.1 201 Created
Location:
Server: MarkLogic
Content-Length: 0
Connection: close
  

Example

$ cat added-constraint.json
{
  "options": {
    "constraint": [
      {
        "name": "title",
        "word": {
          "element": {
            "ns": "",
            "name": "TITLE"
          }
        }
      }
    ]
  }
}

$ curl --anyauth --user user:password -i -X POST -d@"added-constraint.json" \
    -H "Content-type: application/json" \
    http://localhost:8000/v1/config/query/my-options/constraint

==> The "title" constraint is added to the "my-options" query options. If
    the query options already contain other <constraint/> elements, they 
    are unchanged.  MarkLogic Server returns the following headers:

HTTP/1.1 201 Created
Location:
Server: MarkLogic
Content-Length: 0
Connection: close
  
Powered by MarkLogic Server | Terms of Use | Privacy Policy