Skip to content

Global Search: Add Chinese and Japanese languages support

Dmitry Gruzd requested to merge 244347-es-add-language-support into master

What does this MR do?

This MR implements support for 2 elasticsearch analysis plugins: smartcn and kuromoji to improve Chinese and Japanese languages support. This is an optional feature and requires plugin(s) installation.

When Searching is enabled, part of the query changes:

before
{
  "simple_query_string": {
    "_name": "issue:match:search_terms",
    "fields": [
      "title^2",
      "description"
    ],
    "query": "some_query",
    "default_operator": "or"
  }
}
after
{
  "simple_query_string": {
    "_name": "issue:match:search_terms",
    "fields": [
      "title^2",
      "description",
      "title.smartcn",
      "title.kuromoji",
      "description.smartcn",
      "description.kuromoji"
    ],
    "query": "some_query",
    "default_operator": "or"
  }
}

We add additional indexed fields for title and description to the list of fields

#244347 (closed)

Migrations

Click to see migrations details

db:migrate:up

== 20201019101549 AddEsCustomAnalyzersSettings: migrating =====================
-- add_column(:application_settings, :elasticsearch_analyzers_smartcn_enabled, :bool, {:null=>false, :default=>false})
   -> 0.0028s
-- add_column(:application_settings, :elasticsearch_analyzers_smartcn_search, :bool, {:null=>false, :default=>false})
   -> 0.0013s
-- add_column(:application_settings, :elasticsearch_analyzers_kuromoji_enabled, :bool, {:null=>false, :default=>false})
   -> 0.0010s
-- add_column(:application_settings, :elasticsearch_analyzers_kuromoji_search, :bool, {:null=>false, :default=>false})
   -> 0.0010s
== 20201019101549 AddEsCustomAnalyzersSettings: migrated (0.0062s) ============

db:migrate:down

== 20201019101549 AddEsCustomAnalyzersSettings: reverting =====================
-- remove_column(:application_settings, :elasticsearch_analyzers_kuromoji_search, :bool, {:null=>false, :default=>false})
   -> 0.0026s
-- remove_column(:application_settings, :elasticsearch_analyzers_kuromoji_enabled, :bool, {:null=>false, :default=>false})
   -> 0.0008s
-- remove_column(:application_settings, :elasticsearch_analyzers_smartcn_search, :bool, {:null=>false, :default=>false})
   -> 0.0007s
-- remove_column(:application_settings, :elasticsearch_analyzers_smartcn_enabled, :bool, {:null=>false, :default=>false})
   -> 0.0007s
== 20201019101549 AddEsCustomAnalyzersSettings: reverted (0.0063s) ============

Screenshots

Screenshot_2020-10-22_at_11.05.13

Useful links

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team

Related to #244347 (closed)

Edited by Dmitry Gruzd

Merge request reports