From e58ce86264619f0cdd8ffcf7df25b7e07eb990da Mon Sep 17 00:00:00 2001 From: Mai-Lapyst Date: Tue, 4 Jun 2024 07:37:59 +0000 Subject: [PATCH] Update the elasticsearch mappings for issues to use long instead of integer for int64 (#3982) This updates the mapping definition of the elasticsearch issue indexer backend to use `long` instead of `integer`s wherever the go type is a `int64`. Without it larger instances could run into an issue. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3982 Reviewed-by: Earl Warren Co-authored-by: Mai-Lapyst Co-committed-by: Mai-Lapyst --- .forgejo/workflows/testing.yml | 5 +++ .../issues/elasticsearch/elasticsearch.go | 32 +++++++++---------- .../elasticsearch/elasticsearch_test.go | 3 +- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/.forgejo/workflows/testing.yml b/.forgejo/workflows/testing.yml index 3e265e7099..8668c638ac 100644 --- a/.forgejo/workflows/testing.yml +++ b/.forgejo/workflows/testing.yml @@ -45,6 +45,10 @@ jobs: container: image: 'docker.io/node:20-bookworm' services: + elasticsearch: + image: elasticsearch:7.5.0 + env: + discovery.type: single-node minio: image: bitnami/minio:2024.3.30 options: >- @@ -85,6 +89,7 @@ jobs: RACE_ENABLED: 'true' TAGS: bindata TEST_REDIS_SERVER: redis:6379 + TEST_ELASTICSEARCH_URL: http://elasticsearch:9200 test-mysql: if: ${{ !startsWith(vars.ROLE, 'forgejo-') }} runs-on: docker diff --git a/modules/indexer/issues/elasticsearch/elasticsearch.go b/modules/indexer/issues/elasticsearch/elasticsearch.go index c7cb59f2cf..064d7dd37c 100644 --- a/modules/indexer/issues/elasticsearch/elasticsearch.go +++ b/modules/indexer/issues/elasticsearch/elasticsearch.go @@ -48,8 +48,8 @@ const ( { "mappings": { "properties": { - "id": { "type": "integer", "index": true }, - "repo_id": { "type": "integer", "index": true }, + "id": { "type": "long", "index": true }, + "repo_id": { "type": "long", "index": true }, "is_public": { "type": "boolean", "index": true }, "title": { "type": "text", "index": true }, @@ -58,22 +58,22 @@ const ( "is_pull": { "type": "boolean", "index": true }, "is_closed": { "type": "boolean", "index": true }, - "label_ids": { "type": "integer", "index": true }, + "label_ids": { "type": "long", "index": true }, "no_label": { "type": "boolean", "index": true }, - "milestone_id": { "type": "integer", "index": true }, - "project_id": { "type": "integer", "index": true }, - "project_board_id": { "type": "integer", "index": true }, - "poster_id": { "type": "integer", "index": true }, - "assignee_id": { "type": "integer", "index": true }, - "mention_ids": { "type": "integer", "index": true }, - "reviewed_ids": { "type": "integer", "index": true }, - "review_requested_ids": { "type": "integer", "index": true }, - "subscriber_ids": { "type": "integer", "index": true }, - "updated_unix": { "type": "integer", "index": true }, + "milestone_id": { "type": "long", "index": true }, + "project_id": { "type": "long", "index": true }, + "project_board_id": { "type": "long", "index": true }, + "poster_id": { "type": "long", "index": true }, + "assignee_id": { "type": "long", "index": true }, + "mention_ids": { "type": "long", "index": true }, + "reviewed_ids": { "type": "long", "index": true }, + "review_requested_ids": { "type": "long", "index": true }, + "subscriber_ids": { "type": "long", "index": true }, + "updated_unix": { "type": "long", "index": true }, - "created_unix": { "type": "integer", "index": true }, - "deadline_unix": { "type": "integer", "index": true }, - "comment_count": { "type": "integer", "index": true } + "created_unix": { "type": "long", "index": true }, + "deadline_unix": { "type": "long", "index": true }, + "comment_count": { "type": "long", "index": true } } } } diff --git a/modules/indexer/issues/elasticsearch/elasticsearch_test.go b/modules/indexer/issues/elasticsearch/elasticsearch_test.go index 6989532ae5..4ed0b84442 100644 --- a/modules/indexer/issues/elasticsearch/elasticsearch_test.go +++ b/modules/indexer/issues/elasticsearch/elasticsearch_test.go @@ -14,8 +14,7 @@ import ( ) func TestElasticsearchIndexer(t *testing.T) { - t.Skip("elasticsearch not found in Forgejo test yet") - // The elasticsearch instance started by pull-db-tests.yml > test-unit > services > elasticsearch + // The elasticsearch instance started by testing.yml > test-unit > services > elasticsearch url := "http://elastic:changeme@elasticsearch:9200" if os.Getenv("CI") == "" {