• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript elasticsearch.Client类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中elasticsearch.Client的典型用法代码示例。如果您正苦于以下问题:TypeScript Client类的具体用法?TypeScript Client怎么用?TypeScript Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Client类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: addToIndex

 addToIndex(value): Observable<any> {
     var client = new elasticsearch.Client({
         host: 'http://localhost:9200',
         log: 'trace'
     });
     return Observable.fromPromise(client.create(value))
 }
开发者ID:cwdonnelly,项目名称:angular2-elastic,代码行数:7,代码来源:elasticsearch.service.ts


示例2: 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


示例3: 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


示例4: search

    search(value): Observable<any> {
        if (value) {
            console.log(value)
            var client = new elasticsearch.Client({
                host: 'http://localhost:9200',
                log: 'trace'
            });
            return Observable.fromPromise(client.search({
                index: 'blog',
                q: `title:${value}`
            }))
        }else{
            return Observable.of({})
        }

    }
开发者ID:cwdonnelly,项目名称:angular2-elastic,代码行数:16,代码来源:elasticsearch.service.ts


示例5: loadIntoEs

function loadIntoEs(obj) {
  if (esClient) {
      esClient.create({
      index: 'twitter3',
      type: 'tweet',
      body: obj
    }, function (error, response) {
      if (error) {
        console.log('elasticsearch error: ' + error);
        esClient = null;
      }
    });
  }
}
开发者ID:1337programming,项目名称:twitter-sentiment-analysis,代码行数:14,代码来源:twitter-stream.ts


示例6: insertPackages

function insertPackages(packages: registry.Package[], callback: (error?: Error) => void) {
  logger.debug('inserting batch of %d packages, from %s to %s', packages.length,
    packages[0].name, packages[packages.length - 1].name);

  var body = [];
  packages.forEach(pkg => {
    body.push({index: {_id: pkg.name}}, pkg);
  });

  client.bulk({
    index: 'npm',
    type: 'packages',
    body: body
  }, (error: Error, result) => {
    if (error) {
      logger.error('failed to insert batch: %s', error.message);
      return callback(error);
    }
    logger.debug('inserting batch took %d ms', result.took);
    if (result.errors) {
      logger.warning('batch insert encountered non-fatal errors: %j', result.errors);
    }
    callback();
  });
}
开发者ID:chbrown,项目名称:npm-search-server,代码行数:25,代码来源:database.ts


示例7:

 const promises = issues.map(issue => {
     client.index({
         index: 'jira',
         type: 'issues',
         id: issue.id,
         body: issue
     })
 });
开发者ID:antoniohueso,项目名称:sauron2.0,代码行数:8,代码来源:es.ts


示例8: resolve

    return new Promise<UpdaterAck>((resolve, reject) => {
        var to_delete = filter(rows, { __deleted: true }),
            to_create = filter(rows, { __deleted: false, __created: true }),
            to_update = filter(rows, { __deleted: false, __created: false });

        log.debug('bulk elasticsearch edit');
        log.debug('creating %s %s', to_create.length, def.name);
        log.debug('updating %s %s', to_update.length, def.name);
        log.debug('deleting %s %s', to_delete.length, def.name);

        if (!rows.length) {
            return resolve({ ok: true, def });
        }

        es.bulk({
            body: prep_body(rows.reduce((edit, row) => {
                if (row.__deleted) {
                    append(edit, {
                        delete: gen_index(def, row)
                    });
                } else {
                    append(edit, {
                        index: gen_index(def, row)
                    });

                    append(edit, merge({
                        __label: row.__label
                    }, pick(row, def.fields)));
                }

                return edit;
            }, []))
        })
            .then(ack => {
                if (ack.errors) {
                    throw new ElasticsearchBulkUpdateError(def.name, ack);
                }

                log.debug('done pushing updates to %s', def.name);
                log.debug('took: %s, errors: %s', ack.took, ack.errors);
                resolve({ ok: !ack.errors, def });
            })
            .catch(ElasticsearchBulkUpdateError, err => {
                log.error('error making bulk update', err.ack.items);
                reject(err);
            })
            .catch(err => {
                log.error(err);
                log.error('error running elasticsearch update for %s. %s',
                    def.name, err.stack);

                reject(err);
            });
    });
开发者ID:consumr-project,项目名称:cp,代码行数:54,代码来源:updater.ts


示例9: search

 /*
     search(value): Promise<SearchResponse<any>> {
         if (value) {
             console.log(value)
             return this._client.search({
                 index: 'blog',
                 q: `title:${value}`
             })
         } else {
             return Promise.resolve({})
         }
     }
 
     addToIndex(value): Promise<any> {
         return this._client.create(value)
     }
 
     isAvailable(): Promise<any> {
         return this._client.ping({
             requestTimeout: Infinity,
             hello: "elasticsearch!"
         });
     }*/
 search(value): any {
     if (value) {
         console.log(value)
         return this._client.search({
             index: 'blog',
             q: `title:${value}`
         })
     } else {
         return Promise.resolve({})
     }
 }
开发者ID:byavv,项目名称:angular2-elastic,代码行数:34,代码来源:elasticsearch.service.ts


示例10:

 users.map(user => user.dataValues).forEach(user => {
   client.index({
     index,
     type: "user",
     id: user.id,
     body: {
       first_name: user.first_name,
       last_name: user.last_name,
       location: user.location
     }
   });
 });
开发者ID:jord-goldberg,项目名称:api_take_home,代码行数:12,代码来源:elasticsearch.ts



注:本文中的elasticsearch.Client类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript electron.BrowserWindow类代码示例发布时间:2022-05-25
下一篇:
TypeScript ekkiog-editing.getTileAt函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap