occultskyrong / blog2

个人博客2.x版本,重新组织项目结构,使用hexo构建;整合原blog内容。
http://blog2.sky91.cn
MIT License
4 stars 0 forks source link

To be archived #1

Open occultskyrong opened 5 years ago

occultskyrong commented 5 years ago

待归档issue列表

occultskyrong commented 5 years ago

https://github.com/beautify-web/js-beautify/issues/382

解决vscodebeautify插件中析构赋值换行的格式化问题

occultskyrong commented 5 years ago

_type的变更

ElasticSearch在7.x中删除type

Indices created in Elasticsearch 6.0.0 or later may only contain a single mapping type.

Indices created in 5.x with multiple mapping types will continue to function as before in Elasticsearch 6.x.

Mapping types will be completely removed in Elasticsearch 7.0.0.

参考

为什么ElasticSearch要在7.X版本去掉type?

Elasticsearch 6.0 Removal of mapping types

Elasticsearch Reference [6.x] » Mapping » Removal of mapping types

Indices, types, and parent / child: current status and upcoming changes in Elasticsearch

时间线

Elasticsearch 5.6.0

Setting index.mapping.single_type: true on an index will enable the single-type-per-index behaviour which will be enforced in 6.0.

The join field replacement for parent-child is available on indices created in 5.6.

Elasticsearch 6.x

Indices created in 5.x will continue to function in 6.x as they did in 5.x.

Indices created in 6.x only allow a single-type per index. Any name can be used for the type, but there can be only one. The preferred type name is _doc, so that index APIs have the same path as they will have in 7.0: PUT {index}/_doc/{id} and POST {index}/_doc

The _type name can no longer be combined with the _id to form the _uid field. The _uid field has become an alias for the _id field.

New indices no longer support the old-style of parent/child and should use the join field instead.

The default mapping type is deprecated.

Elasticsearch 7.x

The type parameter in URLs are deprecated. For instance, indexing a document no longer requires a document type. The new index APIs are PUT {index}/_doc/{id} in case of explicit ids and POST {index}/_doc for auto-generated ids.

The index creation, GET|PUT _mapping and document APIs support a query string parameter (include_type_name) which indicates whether requests and responses should include a type name. It defaults to true. 7.x indices which don’t have an explicit type will use the dummy type name _doc. Not setting include_type_name=false will result in a deprecation warning.

The default mapping type is removed.

Elasticsearch 8.x

The type parameter is no longer supported in URLs.

The include_type_name parameter is deprecated, default to false and fails the request when set to true.

Elasticsearch 9.x

The include_type_name parameter is removed.

occultskyrong commented 5 years ago

基于桶的多分片聚合结果可能存在偏差

Document counts are approximate

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#search-aggregations-bucket-terms-aggregation-approximate-counts

Calculating Document Count Erroredit

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#_calculating_document_count_error

occultskyrong commented 5 years ago

聚合结果可被缓存

https://www.elastic.co/guide/en/elasticsearch/reference/current/caching-heavy-aggregations.html

https://www.elastic.co/guide/en/elasticsearch/reference/current/shard-request-cache.html

occultskyrong commented 5 years ago

删除ElasticSearch中重复文档

https://alexmarquardt.com/2018/07/23/deduplicating-documents-in-elasticsearch/

occultskyrong commented 5 years ago

从大量数据中查询某个值

布隆过滤

occultskyrong commented 5 years ago

ElasticSearch内存管理

Elasticsearch Reference [6.5] » cat APIs » cat segments Understanding the Memory Pressure Indicator Day19 ES内存那点事

occultskyrong commented 5 years ago

pm2不自动重启

--no-autorestart https://github.com/Unitech/pm2/issues/2286

occultskyrong commented 5 years ago

并发量测试工具

benchmark

并发+同步(promise)

https://github.com/bestiejs/benchmark.js/issues/29

const Benchmark = require('benchmark');
const mongoose = require('mongoose');

const { mongodb } = require('../../config');

mongoose.connect(`mongodb://${mongodb.host}:${mongodb.port}/transaction`, {
  useNewUrlParser: true,
  poolSize: 10,
});

const { Schema } = mongoose;
const db = mongoose.connection;

const Log = db.model('Log', new Schema({ timestamp: Date }));

async function createLog(session) {
  if (session) {
    await Log.create({ timestamp: new Date().getTime() }, { session });
  } else {
    await Log.create({ timestamp: new Date().getTime() });
  }
  return true;
}

// 直接创建
const create = deferred => Log
  .createCollection()
  .then(() => createLog())
  .then(() => deferred.resolve());

// 使用事务创建
const transacion = (deferred) => {
  let session;
  return Log
    .createCollection()
    .then(() => db.startSession())
    .then((_session) => {
      session = _session;
      session.startTransaction();
      return createLog(session);
    })
    .then(() => session.commitTransaction())
    .then(() => deferred.resolve());
};

const suite = new Benchmark.Suite();

async function run() {
  // add tests
  suite
    .add('transaction', transacion, { defer: true })
    .add('create', create, { defer: true })
    .on('cycle', event => console.info(String(event.target)))
    .on('complete', () => console.info('--- Completed ---'))
    // run async
    .run({ async: true });
}

run()
  .then()
  .catch(console.error);
occultskyrong commented 5 years ago

MySQL的ORM或builder

sequelize knex dresende / node-orm2

occultskyrong commented 5 years ago

elasticsearch field multiple types

https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-fields.html https://discuss.elastic.co/t/same-field-name-with-different-data-types-in-the-same-index/63758 https://logz.io/blog/elasticsearch-mapping/