本文整理匯總了TypeScript中elasticsearch.Client.ping方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Client.ping方法的具體用法?TypeScript Client.ping怎麽用?TypeScript Client.ping使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類elasticsearch.Client
的用法示例。
在下文中一共展示了Client.ping方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: isAvailable
isAvailable(): Promise<any> {
var client = new elasticsearch.Client({
host: 'http://localhost:9200',
log: 'trace'
});
return client.ping({
requestTimeout: Infinity,
hello: "elasticsearch!"
});
}
示例2: before
before(done => {
client = new ElasticSearch.Client({
host: "localhost:9200",
apiVersion: "2.3"
});
client.ping({
requestTimeout: Infinity
}, error => {
if (error) {
done(error);
} else {
done();
}
});
});
示例3:
let client = new elasticsearch.Client({
host: 'localhost:9200',
log: 'trace'
});
client = new elasticsearch.Client({
hosts: [
'box1.server.org',
'box2.server.org'
],
selector: (hosts: any) => { }
});
client.ping({
requestTimeout: 30000
}, (error) => {
});
client.search({
q: 'pants'
}).then((body) => {
const hits = body.hits.hits;
}, (error) => {
});
client.indices.delete({
index: 'test_index',
ignore: [404]
}).then((body) => {
}, (error) => {
});
示例4:
import * as elasticsearch from 'elasticsearch';
import config from '../config';
// Init ElasticSearch connection
const client = new elasticsearch.Client({
host: `${config.elasticsearch.host}:${config.elasticsearch.port}`
});
// Send a HEAD request
client.ping({
// Ping usually has a 3000ms timeout
requestTimeout: Infinity,
// Undocumented params are appended to the query string
hello: 'elasticsearch!'
}, error => {
if (error) {
console.error('elasticsearch is down!');
}
});
export default client;
示例5: require
//////////////////////////////////////////////////
// SEARCH DB
//////////////////////////////////////////////////
import * as cluster from 'cluster';
const elasticsearch = require('elasticsearch');
import config from '../config';
// init ElasticSearch connection
const client = new elasticsearch.Client({
host: `${config.elasticsearch.host}:${config.elasticsearch.port}`
});
// Send a HEAD request
client.ping({
// ping usually has a 3000ms timeout
requestTimeout: Infinity,
// undocumented params are appended to the query string
hello: "elasticsearch!"
}, (error: any) => {
if (error) {
console.error('elasticsearch cluster is down!');
} else {
console.log(`[${cluster.worker.id}] Connected to Elasticsearch`);
}
});
export default client;
示例6: isAvailable
isAvailable(): any {
return this._client.ping({
requestTimeout: Infinity,
hello: "elasticsearch!"
});
}