Elastic Search Issue Indexer fuzzy search #5587

Open
opened 2025-11-02 06:29:52 -06:00 by GiteaMirror · 11 comments
Owner

Originally created by @WegnerDan on GitHub (Jun 19, 2020).

Description

I have set up elasticsearch with the following settings:

[indexer]
REPO_INDEXER_ENABLED = true
ISSUE_INDEXER_TYPE: elasticsearch
ISSUE_INDEXER_CONN_STR: http://localhost:9200
ISSUE_INDEXER_NAME: gitea_issues

I have created a test issue with the text "bla bla bla mr. freeman" and I am trying to find it using the issue search. I've done the same thing on the try.gitea.io test instance:

Issue: https://try.gitea.io/thedoginthewok/test_issue_search/issues/1
Search: https://try.gitea.io/issues?type=your_repositories&repos=%5B%5D&sort=&state=open&q=freema

On the test instance, the issue is successfully found. On my instance, I can only find the instance if I search for the complete word freeman.

Is there any way to configure a fuzzy search for elastic?

Screenshots

My instance with search term freeman:
grafik

My instance with search term freema:
grafik

Originally created by @WegnerDan on GitHub (Jun 19, 2020). <!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue --> <!-- 1. Please speak English, this is the language all maintainers can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 1.12.0 - Git version: 2.16.4 - Operating system: SLES 15.1 - Database: - [x] PostgreSQL - [ ] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [x] No - [ ] Not relevant - Log gist: https://gist.github.com/thedoginthewok/56fa4db31d560a1b40eeee5fe7431a5b ## Description I have set up elasticsearch with the following settings: ``` [indexer] REPO_INDEXER_ENABLED = true ISSUE_INDEXER_TYPE: elasticsearch ISSUE_INDEXER_CONN_STR: http://localhost:9200 ISSUE_INDEXER_NAME: gitea_issues ``` I have created a test issue with the text "bla bla bla mr. freeman" and I am trying to find it using the issue search. I've done the same thing on the try.gitea.io test instance: Issue: https://try.gitea.io/thedoginthewok/test_issue_search/issues/1 Search: https://try.gitea.io/issues?type=your_repositories&repos=%5B%5D&sort=&state=open&q=freema On the test instance, the issue is successfully found. On my instance, I can only find the instance if I search for the complete word freeman. Is there any way to configure a fuzzy search for elastic? ## Screenshots My instance with search term freeman: ![grafik](https://user-images.githubusercontent.com/6908247/85125766-84878300-b22c-11ea-9109-e03c70000f88.png) My instance with search term freema: ![grafik](https://user-images.githubusercontent.com/6908247/85125825-9832e980-b22c-11ea-9ade-81315676e4f9.png) <!-- **If this issue involves the Web Interface, please include a screenshot** -->
GiteaMirror added the issue/confirmedtype/enhancement labels 2025-11-02 06:29:52 -06:00
Author
Owner

@lunny commented on GitHub (Jun 19, 2020):

Maybe you mean

[indexer]
REPO_INDEXER_ENABLED = true
ISSUE_INDEXER_TYPE = elasticsearch
ISSUE_INDEXER_CONN_STR = http://localhost:9200
ISSUE_INDEXER_NAME = gitea_issues
@lunny commented on GitHub (Jun 19, 2020): Maybe you mean ``` [indexer] REPO_INDEXER_ENABLED = true ISSUE_INDEXER_TYPE = elasticsearch ISSUE_INDEXER_CONN_STR = http://localhost:9200 ISSUE_INDEXER_NAME = gitea_issues ```
Author
Owner

@WegnerDan commented on GitHub (Jun 19, 2020):

I've changed it to "=", but it behaves the same.

New log gist: https://gist.github.com/thedoginthewok/eaa51d81d8a82f13145ff7be1c56888b

This part is interesting to me:

2020/06/19 15:25:41 ...elastic/v7/client.go:848:dumpRequest() [T] POST /gitea_issues/_search HTTP/1.1\01503d
	Host: localhost:9200\01503d
	User-Agent: elastic/7.0.9 (linux-amd64)\01503d
	Transfer-Encoding: chunked\01503d
	Accept: application/json\01503d
	Content-Type: application/json\01503d
	Accept-Encoding: gzip\01503d
	\01503d
	b5\01503d
	{"from":0,"query":{"bool":{"must":[{"multi_match":{"fields":["title","content","comments"],"query":"freema"}},{"terms":{"repo_id":[1]}}]}},"size":50,"sort":[{"id":{"order":"asc"}}]}\01503d
	0\01503d
	\01503d
	
2020/06/19 15:25:41 ...elastic/v7/client.go:858:dumpResponse() [T] HTTP/1.1 200 OK\01503d
	Content-Type: application/json; charset=UTF-8\01503d
	\01503d
	{"took":4,"timed_out":false,"_shards":{"total":1,"successful":1,"skipped":0,"failed":0},"hits":{"total":{"value":0,"relation":"eq"},"max_score":null,"hits":[]}}

@WegnerDan commented on GitHub (Jun 19, 2020): I've changed it to "=", but it behaves the same. New log gist: https://gist.github.com/thedoginthewok/eaa51d81d8a82f13145ff7be1c56888b This part is interesting to me: ``` 2020/06/19 15:25:41 ...elastic/v7/client.go:848:dumpRequest() [T] POST /gitea_issues/_search HTTP/1.1\01503d Host: localhost:9200\01503d User-Agent: elastic/7.0.9 (linux-amd64)\01503d Transfer-Encoding: chunked\01503d Accept: application/json\01503d Content-Type: application/json\01503d Accept-Encoding: gzip\01503d \01503d b5\01503d {"from":0,"query":{"bool":{"must":[{"multi_match":{"fields":["title","content","comments"],"query":"freema"}},{"terms":{"repo_id":[1]}}]}},"size":50,"sort":[{"id":{"order":"asc"}}]}\01503d 0\01503d \01503d 2020/06/19 15:25:41 ...elastic/v7/client.go:858:dumpResponse() [T] HTTP/1.1 200 OK\01503d Content-Type: application/json; charset=UTF-8\01503d \01503d {"took":4,"timed_out":false,"_shards":{"total":1,"successful":1,"skipped":0,"failed":0},"hits":{"total":{"value":0,"relation":"eq"},"max_score":null,"hits":[]}} ```
Author
Owner

@lafriks commented on GitHub (Jun 20, 2020):

Try searching freema*

@lafriks commented on GitHub (Jun 20, 2020): Try searching `freema*`
Author
Owner

@WegnerDan commented on GitHub (Jun 20, 2020):

grafik

Nope.
What is the try.gitea.io instance running on?

@WegnerDan commented on GitHub (Jun 20, 2020): ![grafik](https://user-images.githubusercontent.com/6908247/85199875-0cd05b80-b2f3-11ea-86f2-42ea05a8bffb.png) Nope. What is the try.gitea.io instance running on?
Author
Owner

@lafriks commented on GitHub (Jun 20, 2020):

It just uses database search

@lafriks commented on GitHub (Jun 20, 2020): It just uses database search
Author
Owner

@WegnerDan commented on GitHub (Jun 20, 2020):

So, probably with LIKE '%SEARCHTERM%'.

This is a bug in the elasticsearch indexer, right?
Or is it supposed to work this way?

@WegnerDan commented on GitHub (Jun 20, 2020): So, probably with `LIKE '%SEARCHTERM%'`. This is a bug in the elasticsearch indexer, right? Or is it supposed to work this way?
Author
Owner

@lafriks commented on GitHub (Jun 20, 2020):

Elastic search query should be improved

@lafriks commented on GitHub (Jun 20, 2020): Elastic search query should be improved
Author
Owner

@lunny commented on GitHub (Jun 21, 2020):

That's because how we use elastic search. Below is the configuration from the source,

"mappings": {
			"properties": {
				"id": {
					"type": "integer",
					"index": true
				},
				"repo_id": {
					"type": "integer",
					"index": true
				},
				"title": {
					"type": "text",
					"index": true
				},
				"content": {
					"type": "text",
					"index": true
				},
				"comments": {
					"type" : "text",
					"index": true
				}
			}
		}

We should change the configuration to resolve the problem?

@lunny commented on GitHub (Jun 21, 2020): That's because how we use elastic search. Below is the configuration from the source, ``` "mappings": { "properties": { "id": { "type": "integer", "index": true }, "repo_id": { "type": "integer", "index": true }, "title": { "type": "text", "index": true }, "content": { "type": "text", "index": true }, "comments": { "type" : "text", "index": true } } } ``` We should change the configuration to resolve the problem?
Author
Owner

@stale[bot] commented on GitHub (Aug 23, 2020):

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

@stale[bot] commented on GitHub (Aug 23, 2020): This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.
Author
Owner

@stale[bot] commented on GitHub (Sep 7, 2020):

This issue has been automatically closed because of inactivity. You can re-open it if needed.

@stale[bot] commented on GitHub (Sep 7, 2020): This issue has been automatically closed because of inactivity. You can re-open it if needed.
Author
Owner

@WegnerDan commented on GitHub (Sep 29, 2020):

unstale

@WegnerDan commented on GitHub (Sep 29, 2020): unstale
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#5587