218 lines
7.2 KiB
HTML
218 lines
7.2 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>src/api/indices/validate_query.js - elasticsearch-js</title>
|
|
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
|
|
<link rel="stylesheet" href="../assets/vendor/bootstrap/css/bootstrap.css">
|
|
<link rel="stylesheet" href="../assets/vendor/bootstrap/css/bootstrap-responsive.css">
|
|
<link rel="stylesheet" href="../assets/css/main.css">
|
|
<link rel="shortcut icon" type="image/png" href="../assets/img/favicon.png">
|
|
</head>
|
|
<body>
|
|
<nav class="navbar navbar-default" role="navigation">
|
|
<!-- Brand and toggle get grouped for better mobile display -->
|
|
<a class="navbar-brand" href="#">elasticsearch-js</a>
|
|
<p class="navbar-text">
|
|
API Docs for Version: <b>0.0.1</b>
|
|
</p>
|
|
|
|
<form class="navbar-form navbar-right visible-md visible-large" role="search">
|
|
<div class="form-group">
|
|
<input type="text" class="form-control" placeholder="Search">
|
|
</div>
|
|
</form>
|
|
</nav>
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="col-md-3">
|
|
<div>
|
|
<h3>APIs</h3>
|
|
<div id="sidebar">
|
|
<ul id="main-nav" class="nav nav-tabs" style="margin-bottom:0;">
|
|
|
|
<li class="active" style="visibility:hidden;"><a>just classes</a></li>
|
|
|
|
</ul>
|
|
|
|
<div id="api-tabview-filter">
|
|
<input type="search" placeholder="Type to filter APIs">
|
|
</div>
|
|
|
|
<div class="tab-content" style="border: 1px solid #DDD; border-top:0;">
|
|
<div class="tab-pane active" id="classes">
|
|
<ul id="api-classes" class="nav nav-list">
|
|
|
|
<li><a href="../classes/Client.html">Client</a></li>
|
|
|
|
<li><a href="../classes/ConnectionPool.html">ConnectionPool</a></li>
|
|
|
|
<li><a href="../classes/jQueryXhr.html">jQueryXhr</a></li>
|
|
|
|
<li><a href="../classes/Log.html">Log</a></li>
|
|
|
|
<li><a href="../classes/Loggers.File.html">Loggers.File</a></li>
|
|
|
|
<li><a href="../classes/Loggers.Stdio.html">Loggers.Stdio</a></li>
|
|
|
|
<li><a href="../classes/Loggers.Stream.html">Loggers.Stream</a></li>
|
|
|
|
<li><a href="../classes/NodeHttp.html">NodeHttp</a></li>
|
|
|
|
<li><a href="../classes/Transport.html">Transport</a></li>
|
|
|
|
<li><a href="../classes/utils.html">utils</a></li>
|
|
|
|
</ul>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
<div class="col-md-9">
|
|
|
|
<div id="docs-main">
|
|
<div class="content">
|
|
<div class="page-header">
|
|
<h1>src/api/indices/validate_query.js <small>File</small></h1>
|
|
</div>
|
|
|
|
<div class="file">
|
|
<pre class="prettyprint linenums">
|
|
var _ = require('../../lib/utils');
|
|
|
|
var ignoreIndicesOptions = ['none', 'missing'];
|
|
|
|
|
|
|
|
/**
|
|
* Perform an elasticsearch [indices.validate_query](http://www.elasticsearch.org/guide/reference/api/validate/) request
|
|
*
|
|
* @for Client
|
|
* @method indices.validate_query
|
|
* @param {Object} params - An object with parameters used to carry out this action
|
|
* @param {boolean} params.explain - Return detailed information about the error
|
|
* @param {String} [params.ignore_indices=none] - When performed on multiple indices, allows to ignore `missing` ones
|
|
* @param {*} params.operation_threading - TODO: ?
|
|
* @param {string} params.source - The URL-encoded query definition (instead of using the request body)
|
|
* @param {string} params.q - Query in the Lucene query string syntax
|
|
*/
|
|
function doIndicesValidateQuery(params) {
|
|
var request = {}
|
|
, url = {}
|
|
, query = {};
|
|
|
|
params = params || {};
|
|
|
|
if (param.method) {
|
|
if (param.method === 'GET' || param.method === 'POST') {
|
|
request.method = param.method;
|
|
} else {
|
|
throw new TypeError('Invalid method: should be one of GET, POST');
|
|
}
|
|
} else {
|
|
request.method = 'GET';
|
|
}
|
|
|
|
// find the url's params
|
|
if (params.hasOwnProperty('index')) {
|
|
if (typeof params.index === 'string') {
|
|
url.index = params.index;
|
|
} else if (_.isArray(params.index)) {
|
|
url.index = params.index.join(',');
|
|
} else {
|
|
throw new TypeError('Invalid index:' + params.index + ' should be a comma seperated list or array.');
|
|
}
|
|
}
|
|
|
|
if (params.hasOwnProperty('type')) {
|
|
if (typeof params.type === 'string') {
|
|
url.type = params.type;
|
|
} else if (_.isArray(params.type)) {
|
|
url.type = params.type.join(',');
|
|
} else {
|
|
throw new TypeError('Invalid type:' + params.type + ' should be a comma seperated list or array.');
|
|
}
|
|
}
|
|
|
|
|
|
// build the url
|
|
if (url.hasOwnProperty('index') && url.hasOwnProperty('type')) {
|
|
request.url = '/' + url.index + '/' + url.type + '/_validate/query';
|
|
}
|
|
else if (url.hasOwnProperty('index')) {
|
|
request.url = '/' + url.index + '/_validate/query';
|
|
}
|
|
else {
|
|
request.url = '/_validate/query';
|
|
}
|
|
|
|
|
|
// build the query string
|
|
if (params.hasOwnProperty('explain')) {
|
|
if (params.explain.toLowerCase && (params.explain = params.explain.toLowerCase())
|
|
&& (params.explain === 'no' || params.explain === 'off')
|
|
) {
|
|
query.explain = false;
|
|
} else {
|
|
query.explain = !!params.explain;
|
|
}
|
|
}
|
|
|
|
if (params.hasOwnProperty('ignore_indices')) {
|
|
if (_.contains(ignoreIndicesOptions, params.ignore_indices)) {
|
|
query.ignore_indices = params.ignore_indices;
|
|
} else {
|
|
throw new TypeError(
|
|
'Invalid ignore_indices:' + params.ignore_indices +
|
|
' should be one of ' + ignoreIndicesOptions.join(', ') + '.'
|
|
);
|
|
}
|
|
} else {
|
|
query.ignore_indices = 'none';
|
|
}
|
|
|
|
if (params.hasOwnProperty('operation_threading')) {
|
|
query.operation_threading = params.operation_threading;
|
|
}
|
|
|
|
if (params.hasOwnProperty('source')) {
|
|
if (typeof params.source !== 'object' && typeof params.source !== 'undefined') {
|
|
query.source = '' + params.source;
|
|
} else {
|
|
throw new TypeError('Invalid source:' + params.source + ' should be a string.');
|
|
}
|
|
}
|
|
|
|
if (params.hasOwnProperty('q')) {
|
|
if (typeof params.q !== 'object' && typeof params.q !== 'undefined') {
|
|
query.q = '' + params.q;
|
|
} else {
|
|
throw new TypeError('Invalid q:' + params.q + ' should be a string.');
|
|
}
|
|
}
|
|
|
|
request.url = request.url + _.makeQueryString(query);
|
|
|
|
return this.client.request(request);
|
|
}
|
|
|
|
module.exports = doIndicesValidateQuery;
|
|
</pre>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script src="../assets/vendor/jquery/jquery-1.10.2.min.js"></script>
|
|
<script src="../assets/vendor/bootstrap/js/bootstrap.js"></script>
|
|
<script src="../assets/vendor/prettify/prettify-min.js"></script>
|
|
<script src="../assets/js/main.js"></script>
|
|
</body>
|
|
</html>
|