Skip to content

Commit d7f8e05

Browse files
committed
feat: 修复manache无法匹配manacher的问题
1 parent 6067bc5 commit d7f8e05

File tree

4 files changed

+70
-54
lines changed

4 files changed

+70
-54
lines changed

api/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ app.get("/", function (req, res) {
8989
},
9090
{
9191
match: {
92-
standard_content: {
92+
ngram_content: {
9393
query: keyword,
9494
minimum_should_match: "75%",
9595
boost: 2,

build.sh

Lines changed: 67 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,71 @@
11
curl -X DELETE "http://localhost:9200/oiwiki"
22
curl -H'Content-Type: application/json' -XPUT "http://localhost:9200/oiwiki" -d'
33
{
4-
"settings": {
5-
"analysis": {
6-
"analyzer": {
7-
"pinyin_analyzer": {
8-
"tokenizer": "ik_max_word",
9-
"filter": "pinyin_filter"
10-
},
11-
"pinyin_search_analyzer": {
12-
"tokenizer": "ik_max_word"
13-
}
14-
},
15-
"filter": {
16-
"pinyin_filter": {
17-
"type": "pinyin",
18-
"keep_original": true,
19-
"limit_first_letter_length": 16,
20-
"keep_joined_full_pinyin": true
21-
}
22-
}
23-
}
24-
},
25-
"mappings": {
26-
"properties": {
27-
"content": {
28-
"type": "text",
29-
"analyzer": "pinyin_analyzer",
30-
"search_analyzer": "pinyin_search_analyzer"
31-
},
32-
"h2": {
33-
"type": "text",
34-
"analyzer": "pinyin_analyzer",
35-
"search_analyzer": "pinyin_search_analyzer"
36-
},
37-
"title": {
38-
"type": "text",
39-
"analyzer": "pinyin_analyzer",
40-
"search_analyzer": "pinyin_search_analyzer"
41-
},
42-
"url": {
43-
"type": "text"
44-
},
45-
"bold": {
46-
"type": "text",
47-
"analyzer": "pinyin_analyzer",
48-
"search_analyzer": "pinyin_search_analyzer"
49-
},
50-
"standard_content": {
51-
"type": "text"
52-
}
53-
}
54-
}
4+
"settings": {
5+
"index.max_ngram_diff": 9,
6+
"analysis": {
7+
"analyzer": {
8+
"pinyin_analyzer": {
9+
"tokenizer": "ik_max_word",
10+
"filter": "pinyin_filter"
11+
},
12+
"pinyin_search_analyzer": {
13+
"tokenizer": "ik_max_word"
14+
},
15+
"ngram_analyzer": {
16+
"tokenizer": "ngram_tokenizer"
17+
}
18+
},
19+
"filter": {
20+
"pinyin_filter": {
21+
"type": "pinyin",
22+
"keep_original": true,
23+
"limit_first_letter_length": 16,
24+
"keep_joined_full_pinyin": true
25+
}
26+
},
27+
"tokenizer": {
28+
"ngram_tokenizer": {
29+
"type": "ngram",
30+
"min_gram": 1,
31+
"max_gram": 9,
32+
"token_chars": ["letter", "digit"]
33+
}
34+
}
35+
}
36+
},
37+
"mappings": {
38+
"properties": {
39+
"content": {
40+
"type": "text",
41+
"analyzer": "pinyin_analyzer",
42+
"search_analyzer": "pinyin_search_analyzer"
43+
},
44+
"h2": {
45+
"type": "text",
46+
"analyzer": "pinyin_analyzer",
47+
"search_analyzer": "pinyin_search_analyzer"
48+
},
49+
"title": {
50+
"type": "text",
51+
"analyzer": "pinyin_analyzer",
52+
"search_analyzer": "pinyin_search_analyzer"
53+
},
54+
"url": {
55+
"type": "text",
56+
"analyzer": "ngram_analyzer",
57+
"search_analyzer": "ngram_analyzer"
58+
},
59+
"bold": {
60+
"type": "text",
61+
"analyzer": "pinyin_analyzer",
62+
"search_analyzer": "pinyin_search_analyzer"
63+
},
64+
"ngram_content": {
65+
"type": "text",
66+
"analyzer": "ngram_analyzer",
67+
"search_analyzer": "ngram_analyzer"
68+
}
69+
}
70+
}
5571
}'

webhook/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function updateContent(modified, removed) {
110110
url: "/" + filename.replace("/index.md", "/").replace(".md", "/"),
111111
h2: h2,
112112
bold: bold,
113-
standard_content: article,
113+
ngram_content: article,
114114
});
115115
});
116116
removed.forEach((filename) => {

webhook/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const response = client.search({
5959
},
6060
{
6161
match: {
62-
standard_content: {
62+
ngram_content: {
6363
query: keyword,
6464
minimum_should_match: "75%",
6565
boost: 2,

0 commit comments

Comments
 (0)