Commit fbb01ecb by Sxy

fix: 优化

parent ce77d1e5
...@@ -4,7 +4,43 @@ ...@@ -4,7 +4,43 @@
es http://192.168.18.102:9200 es http://192.168.18.102:9200
kibana: http://192.168.18.102:5601 kibana: http://192.168.18.102:5601
cerebro: http://192.168.18.102:3000 cerebro: http://192.168.18.102:3000
索引名: trademark 索引名: trademarkv2
字段 : {
length:"总长度",
cnlength:"中文长度",
enlength:"英文长度",
otherlength:"数字特殊符号长度",
"name" : {
"type" : "keyword",
"fields" : {
"all_pinyin" : { // 为同音字查询设计
"type" : "text",
"analyzer" : "all_pinyin"
},
"english" : { // 为英文查询设计
"type" : "text",
"analyzer" : "english"
},
"jingque" : { // 为精确查询设计
"type" : "text",
"analyzer" : "jingque"
},
"standard" : {
"type" : "text",
"analyzer" : "standard"
},
"tongyici" : { // 为同义词查询设计
"type" : "text",
"analyzer" : "tongyici"
},
"xingjinzi" : {// 为形近字查询设计
"type" : "text",
"analyzer" : "xingjinzi"
}
}
}
}
近似搜索体验地址: http://192.168.18.101:3006/ 近似搜索体验地址: http://192.168.18.101:3006/
``` ```
......
const mongoose = require('mongoose'); const mongoose = require('mongoose');
const config = { const config = {
dbPath: "mongodb://192.168.18.101:27017/trademark" dbPath: "mongodb://192.168.18.101:27017/trademarkv1"
}; };
mongoose.set('debug', true) mongoose.set('debug', true)
......
...@@ -11,9 +11,9 @@ ...@@ -11,9 +11,9 @@
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@elastic/elasticsearch": "^7.14.0", "@elastic/elasticsearch": "^7.14.0",
"axios": "^0.21.1",
"cheerio": "^1.0.0-rc.10", "cheerio": "^1.0.0-rc.10",
"mongoose": "^5.13.7", "exceljs": "^4.3.0",
"puppeteer": "^10.2.0",
"koa": "^2.7.0", "koa": "^2.7.0",
"koa-bodyparser": "^4.2.1", "koa-bodyparser": "^4.2.1",
"koa-convert": "^1.2.0", "koa-convert": "^1.2.0",
...@@ -23,6 +23,6 @@ ...@@ -23,6 +23,6 @@
"koa-router": "^7.4.0", "koa-router": "^7.4.0",
"koa-static": "^5.0.0", "koa-static": "^5.0.0",
"koa-views": "^6.2.0", "koa-views": "^6.2.0",
"axios": "^0.21.1" "mongoose": "^5.13.7"
} }
} }
\ No newline at end of file
...@@ -19,7 +19,7 @@ router.post('/list', async (ctx, next) => { ...@@ -19,7 +19,7 @@ router.post('/list', async (ctx, next) => {
} }
console.log(JSON.stringify(query)) console.log(JSON.stringify(query))
const data = await es.search({ const data = await es.search({
index: "trademarkv1", index: "trademarkv2",
body: query body: query
}) })
const { body: { hits: { total, hits } } } = data; const { body: { hits: { total, hits } } } = data;
......
...@@ -677,9 +677,9 @@ async function start(name, conditions) { ...@@ -677,9 +677,9 @@ async function start(name, conditions) {
const enlength = name.trim().replace(/[^a-zA-Z]/g, '').length; const enlength = name.trim().replace(/[^a-zA-Z]/g, '').length;
const otherlength = length - zhlength - enlength; const otherlength = length - zhlength - enlength;
let searchArry = []; let searchArry = [];
let i = Object.keys(funs).length let len = Object.keys(funs).length
for (let val of conditions) { for (let val of conditions) {
const query = await funs[val](name, length, zhlength, enlength, otherlength, Math.pow(10, i--)); const query = await funs[val](name, length, zhlength, enlength, otherlength, Math.pow(10, len - val + 1));
searchArry.push({ searchArry.push({
bool: query bool: query
}) })
......
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