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

Improve search results #323

Merged
merged 5 commits into from Feb 12, 2019
Merged

Improve search results #323

merged 5 commits into from Feb 12, 2019

Conversation

@qjebbs
Copy link
Contributor

qjebbs commented Jan 17, 2019

Hi,

This PR improved search result, which makes the results ordered by relevance, should work for all languages.

This PR improves search only for new entires, because the following only affects new entires:

SET document_vectors = setweight(to_tsvector(coalesce(title, '')), 'A') || setweight(to_tsvector(coalesce(content, '')), 'B')

PS:

To make Chinese search work, user needs a customized postgres database, which enables zhparser plugin, and the database configured to use this parser by default. Or, users will find nothing while searching with Chinese.

Here is a docker image used by me, in case you want to put it in wiki or document.

git clone https://github.com/qjebbs/zhparser-docker
cd zhparser-docker
docker build -t postgresql-zhparser .
docker run -d --name minifluxdb \
    --restart=always \
    -e POSTGRES_USER=miniflux \
    -e POSTGRES_PASSWORD=miniflux \
    postgresql-zhparser
@qiaoyan

This comment has been minimized.

Copy link

qiaoyan commented Jan 18, 2019

Does searching work through api? Thanks.

@qjebbs

This comment has been minimized.

Copy link
Contributor Author

qjebbs commented Jan 18, 2019

@qiaoyan API doesn't support search, so this PR doesn't benefits it:

miniflux/api/entry.go

Lines 113 to 135 in 6378ad2

func (h *handler) getEntries(w http.ResponseWriter, r *http.Request) {
status := request.QueryStringParam(r, "status", "")
if status != "" {
if err := model.ValidateEntryStatus(status); err != nil {
json.BadRequest(w, r, err)
return
}
}
order := request.QueryStringParam(r, "order", model.DefaultSortingOrder)
if err := model.ValidateEntryOrder(order); err != nil {
json.BadRequest(w, r, err)
return
}
direction := request.QueryStringParam(r, "direction", model.DefaultSortingDirection)
if err := model.ValidateDirection(direction); err != nil {
json.BadRequest(w, r, err)
return
}
limit := request.QueryIntParam(r, "limit", 100)
offset := request.QueryIntParam(r, "offset", 0)

Copy link
Contributor

fguillot left a comment

You should add a new migration file for SQL changes and do not remove the bug fix.

@@ -1,3 +1,3 @@
alter table entries add column document_vectors tsvector;
update entries set document_vectors = to_tsvector(substring(title || ' ' || coalesce(content, '') for 1000000));

This comment has been minimized.

Copy link
@fguillot

fguillot Jan 24, 2019

Contributor

This change has been made to fix the issue #251.

@qjebbs

This comment has been minimized.

Copy link
Contributor Author

qjebbs commented Jan 31, 2019

I just come back from vacation, please review the new commit.

@qjebbs qjebbs force-pushed the qjebbs:improve_search_results branch from ca62a16 to 7cc1558 Jan 31, 2019
@fguillot fguillot merged commit 267b706 into miniflux:master Feb 12, 2019
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@miniflux miniflux locked and limited conversation to collaborators Mar 27, 2019
@qjebbs qjebbs deleted the qjebbs:improve_search_results branch Jul 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
3 participants
You can’t perform that action at this time.