本文整理汇总了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!"
});
}