Commit 5a2f954a by Sxy

fix: 索引

parent 404fa903
......@@ -23,6 +23,7 @@
"koa-router": "^7.4.0",
"koa-static": "^5.0.0",
"koa-views": "^6.2.0",
"mongoose": "^5.13.7"
"mongoose": "^5.13.7",
"pinyin-pro": "^3.3.1"
}
}
\ No newline at end of file
}
const { Name } = require("../model/index");
const es = require("../client/esclient");
const { pinyin } = require('pinyin-pro');
/**
* 往 es中 洗数据
*/
......@@ -9,22 +10,23 @@ async function start() {
let i = 0;
while (where) {
try {
const data = await Name.find(where).sort({ _id: 1 }).limit(1000);
const data = await Name.find(where).sort({ _id: 1 }).limit(10);
if (data.length > 0) {
let array = []
console.log(i++)
console.log("1:", data[0]._id)
for (let val of data) {
array.push({ "index": { "_index": "trademarkv1" } }, {
array.push({ "index": { "_index": "trademarkv3" } }, {
name: val.name.trim(),
length: val.name.trim().length,
cnlength: val.name.trim().replace(/[^\u4E00-\u9FA5]/g, '').length,
enlength: val.name.trim().replace(/[^a-zA-Z]/g, '').length,
otherlength: val.name.trim().replace(/\s*/g, "").length - val.name.trim().replace(/[^\u4E00-\u9FA5]/g, '').length - val.name.trim().replace(/[^a-zA-Z]/g, '').length
otherlength: val.name.trim().replace(/\s*/g, "").length - val.name.trim().replace(/[^\u4E00-\u9FA5]/g, '').length - val.name.trim().replace(/[^a-zA-Z]/g, '').length,
pinyin: pinyin(val.name.trim(), { toneType: 'none' })
})
}
await es.bulk({
index: "trademarkv1",
index: "trademarkv3",
body: array
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment