當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Client.ping方法代碼示例

本文整理匯總了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!"
     });
 }
開發者ID:cwdonnelly,項目名稱:angular2-elastic,代碼行數:10,代碼來源:elasticsearch.service.ts

示例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();
            }
        });
    });
開發者ID:martyn82,項目名稱:aphajs,代碼行數:16,代碼來源:ElasticSearchProjectionStorage.spec.ts

示例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) => {
});
開發者ID:Dru89,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:elasticsearch-tests.ts

示例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;
開發者ID:syuilo,項目名稱:misskey-core,代碼行數:22,代碼來源:elasticsearch.ts

示例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;
開發者ID:syuilo,項目名稱:ssmato.me,代碼行數:29,代碼來源:es.ts

示例6: isAvailable

 isAvailable(): any {
     return this._client.ping({
         requestTimeout: Infinity,
         hello: "elasticsearch!"
     });
 }
開發者ID:byavv,項目名稱:angular2-elastic,代碼行數:6,代碼來源:elasticsearch.service.ts


注:本文中的elasticsearch.Client.ping方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。