Skip to content

Commit c40910c

Browse files
authored
feat: add search engine support used by lucene. (#324)
* feat: add search engine support used by lucene. * update: search engine used by lucene * test: disable unit test SubjectRelationServiceTest, api may change in the future. * build: gen new api-client@0.0.21 and publish to npm center repo in @runikaros/api-client * update: finish global search vue component in console. * build: adjust git ignore config * fix: console build. * docs: move rfcs to single repo. * build: move app to single repo * docs: update github issue template. * build: gen new api-client@0.0.22 and publish to npm center repo in @runikaros/api-client * feat: add file search in global search vue component. * docs: update changelog for pr #324. * feat: add build console task before build server, and fix checkstyle run fail. * fix: unit test cases run fail, and update github workflows build fail package save time. * build: appoint version for package @runikaros. * fix: github ci * fix: SubjectServiceTest
1 parent 9bd4992 commit c40910c

File tree

207 files changed

+3003
-6167
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

207 files changed

+3003
-6167
lines changed

.github/ISSUE_TEMPLATE/bug-report.en.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ body:
3030
options:
3131
- "server"
3232
- "console"
33-
- "app"
3433
- "plugin"
35-
- "rfc"
3634
validations:
3735
required: true
3836

.github/ISSUE_TEMPLATE/bug-report.zh.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ body:
2929
options:
3030
- "服务端 (server)"
3131
- "控制台 (console)"
32-
- "客户端 (app)"
3332
- "插件 (plugin)"
34-
- "RFC (rfcs)"
3533
validations:
3634
required: true
3735

.github/workflows/ikaros-server-ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ jobs:
4444
# Artifact name
4545
name: checkBuild
4646
# A file, directory or wildcard pattern that describes what to upload
47-
path: /home/runner/work/ikaros/ikaros/server/build/reports
47+
path: /home/runner/work/ikaros/ikaros/server/build
4848
# The desired behavior if no files are found using the provided path.
4949
if-no-files-found: warn
5050
# Duration after which artifact will expire in days. 0 means using default retention.Minimum 1 day. Maximum 90 days unless changed from the repository settings page.
51-
retention-days: 3
51+
retention-days: 7
5252
test:
5353
runs-on: ubuntu-latest
5454
steps:
@@ -79,9 +79,9 @@ jobs:
7979
# Artifact name
8080
name: testBuild
8181
# A file, directory or wildcard pattern that describes what to upload
82-
path: /home/runner/work/ikaros/ikaros/server/build/reports
82+
path: /home/runner/work/ikaros/ikaros/server/build
8383
# The desired behavior if no files are found using the provided path.
8484
if-no-files-found: warn
8585
# Duration after which artifact will expire in days. 0 means using default retention.Minimum 1 day. Maximum 90 days unless changed from the repository settings page.
86-
retention-days: 3
86+
retention-days: 7
8787

CHANGELOG.MD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
- 插件的安装卸载
3434
- 文件的管理如展示上传移除查询等
3535
- 条目剧集的展示和修改
36+
- 后台全局查询条目和文件支持
3637

3738
## 依赖
3839

api/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ dependencies {
4040
api "org.springframework.integration:spring-integration-core"
4141
api "org.thymeleaf.extras:thymeleaf-extras-springsecurity6"
4242

43+
// Apache Lucene
44+
api "org.apache.lucene:lucene-core"
45+
api "org.apache.lucene:lucene-queryparser"
46+
api "org.apache.lucene:lucene-highlighter"
47+
api "org.apache.lucene:lucene-backward-codecs"
48+
api 'cn.shenyanchao.ik-analyzer:ik-analyzer'
49+
4350
runtimeOnly 'io.r2dbc:r2dbc-h2'
4451
runtimeOnly 'org.postgresql:postgresql'
4552
runtimeOnly 'org.postgresql:r2dbc-postgresql'
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package run.ikaros.api.constant;
2+
3+
public interface StringConst {
4+
String SPACE = " ";
5+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package run.ikaros.api.search;
2+
3+
import java.util.Set;
4+
import org.pf4j.ExtensionPoint;
5+
6+
public interface IndicesSearchService extends ExtensionPoint {
7+
8+
void removeDocuments(Set<String> termTexts) throws Exception;
9+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package run.ikaros.api.search;
2+
3+
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
4+
5+
import io.swagger.v3.oas.annotations.media.Schema;
6+
import org.springframework.util.MultiValueMap;
7+
import org.springframework.util.StringUtils;
8+
import org.springframework.web.server.ServerWebInputException;
9+
10+
public class SearchParam {
11+
12+
private static final int DEFAULT_LIMIT = 10;
13+
private static final String DEFAULT_HIGHLIGHT_PRE_TAG = "<B>";
14+
private static final String DEFAULT_HIGHLIGHT_POST_TAG = "</B>";
15+
16+
private final MultiValueMap<String, String> query;
17+
18+
public SearchParam(MultiValueMap<String, String> query) {
19+
this.query = query;
20+
}
21+
22+
/**
23+
* Get keyword.
24+
*
25+
* @return keyword
26+
*/
27+
@Schema(name = "keyword", requiredMode = REQUIRED)
28+
public String getKeyword() {
29+
var keyword = query.getFirst("keyword");
30+
if (!StringUtils.hasText(keyword)) {
31+
throw new ServerWebInputException("keyword is required");
32+
}
33+
return keyword;
34+
}
35+
36+
@Schema(name = "limit", defaultValue = "100", maximum = "1000")
37+
public int getLimit() {
38+
var limitString = query.getFirst("limit");
39+
int limit = 0;
40+
if (StringUtils.hasText(limitString)) {
41+
try {
42+
limit = Integer.parseInt(limitString);
43+
} catch (NumberFormatException nfe) {
44+
throw new ServerWebInputException("Failed to get ");
45+
}
46+
}
47+
if (limit <= 0) {
48+
limit = DEFAULT_LIMIT;
49+
}
50+
return limit;
51+
}
52+
53+
@Schema(name = "highlightPreTag", defaultValue = DEFAULT_HIGHLIGHT_PRE_TAG)
54+
public String getHighlightPreTag() {
55+
var highlightPreTag = query.getFirst("highlightPreTag");
56+
if (!StringUtils.hasText(highlightPreTag)) {
57+
highlightPreTag = DEFAULT_HIGHLIGHT_PRE_TAG;
58+
}
59+
return highlightPreTag;
60+
}
61+
62+
@Schema(name = "highlightPostTag", defaultValue = DEFAULT_HIGHLIGHT_POST_TAG)
63+
public String getHighlightPostTag() {
64+
var highlightPostTag = query.getFirst("highlightPostTag");
65+
if (!StringUtils.hasText(highlightPostTag)) {
66+
highlightPostTag = DEFAULT_HIGHLIGHT_POST_TAG;
67+
}
68+
return highlightPostTag;
69+
}
70+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package run.ikaros.api.search;
2+
3+
import java.util.List;
4+
import lombok.Data;
5+
6+
@Data
7+
public class SearchResult<T> {
8+
private List<T> hits;
9+
private String keyword;
10+
private Long total;
11+
private int limit;
12+
private long processingTimeMillis;
13+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package run.ikaros.api.search.file;
2+
3+
import lombok.Data;
4+
import run.ikaros.api.store.enums.FilePlace;
5+
import run.ikaros.api.store.enums.FileType;
6+
7+
@Data
8+
public class FileDoc {
9+
private Long id;
10+
private String name;
11+
private String originalPath;
12+
private String url;
13+
private FileType type;
14+
private FilePlace place;
15+
private String originalName;
16+
}

0 commit comments

Comments
 (0)