Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine search result by customizing analyzer #4456

Merged
merged 3 commits into from Aug 25, 2023

Conversation

JohnNiang
Copy link
Member

@JohnNiang JohnNiang commented Aug 22, 2023

What type of PR is this?

/kind improvement
/area core
/milestone 2.9.x

What this PR does / why we need it:

  • Removes dependency cn.shenyanchao.ik-analyzer:ik-analyzer:9.0.0 due to no significant effect for searching result.
  • Customize our own analyzer with StandardTokenizer, HTMLStripCharFilter and LowerCaseFilterFactory.

Please be aware of that the default field to search has become to content instead of title + excerpt + content. If someone wants to search title only, use title: halo as query string. For more details, please refer to https://lucene.apache.org/core/9_5_0/queryparser/org/apache/lucene/queryparser/flexible/standard/StandardQueryParser.html.

Which issue(s) this PR fixes:

Fixes #4455

Special notes for your reviewer:

Does this PR introduce a user-facing change?

优化本地搜索引擎

@f2c-ci-robot f2c-ci-robot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/improvement Categorizes issue or PR as related to a improvement. labels Aug 22, 2023
@f2c-ci-robot f2c-ci-robot bot added this to the 2.9.x milestone Aug 22, 2023
@f2c-ci-robot f2c-ci-robot bot added the area/core Issues or PRs related to the Halo Core label Aug 22, 2023
@codecov
Copy link

codecov bot commented Aug 22, 2023

Codecov Report

Merging #4456 (fd9e42f) into main (42ef726) will increase coverage by 0.04%.
The diff coverage is 14.70%.

@@             Coverage Diff              @@
##               main    #4456      +/-   ##
============================================
+ Coverage     61.11%   61.15%   +0.04%     
  Complexity     2523     2523              
============================================
  Files           372      372              
  Lines         12942    12940       -2     
  Branches        929      928       -1     
============================================
+ Hits           7909     7913       +4     
+ Misses         4582     4576       -6     
  Partials        451      451              
Files Changed Coverage Δ
.../halo/app/search/post/LucenePostSearchService.java 15.62% <14.70%> (+4.40%) ⬆️

@guqing
Copy link
Member

guqing commented Aug 22, 2023

Hi @JohnNiang, 此 PR 该如何测试,是否会对搜索结果和匹配效果产生影响

@LIlGG
Copy link
Member

LIlGG commented Aug 25, 2023

使用 title 搜索时,文章内的字段也会被匹配到,如下所示
image

另外是否能够提供文档或者其他方式供用户了解 title: xxxexcerpt: xxx 等搜索语法,例如可以使用搜索框的 placeholder 来进行提示。

@JohnNiang
Copy link
Member Author

Hi @LIlGG

Query 解析语法在这里可以看到。不建议用户手动输入查询表达式,更建议在 https://github.com/halo-sigs/plugin-search-widget 中集成。

Copy link
Member

@guqing guqing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@f2c-ci-robot f2c-ci-robot bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 25, 2023
Copy link
Member

@ruibaby ruibaby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@f2c-ci-robot f2c-ci-robot bot added the lgtm Indicates that a PR is ready to be merged. label Aug 25, 2023
@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Aug 25, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: guqing, ruibaby

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@f2c-ci-robot f2c-ci-robot bot merged commit e40b5d2 into halo-dev:main Aug 25, 2023
4 checks passed
@ruibaby ruibaby modified the milestones: 2.9.x, 2.9.0 Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/core Issues or PRs related to the Halo Core kind/improvement Categorizes issue or PR as related to a improvement. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

搜索引擎优化:当标题中存在英文单词时,单词不写全的情况下搜索不到
4 participants