简体   繁体   English

Elasticsearch 用于不确定量 i18n

[英]Elasticsearch for uncertain amount i18n

I am using elasticsearch-php in a laravel project.我在laravel项目中使用 elasticsearch -php

I have a products table like below我有一个如下所示的products

CREATE TABLE `products` (
    `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
    `title` JSON NOT NULL,
);

The title of each product will have multiple languages, and the type of language is uncertain每个产品的标题都会有多种语言,语言类型不确定

+------------+---------------------------------------------------------------------------+
|     id     |                                   title                                   |
+------------+---------------------------------------------------------------------------+
|      1     |{"en-US":"Toyota Cruiser","ja-JP":"トヨタクルーザー","zh-CN":"丰田酷路泽"}    |
+------------+---------------------------------------------------------------------------+
|      2     |{"en-US":"Subaru Outback","ja-JP":"スバルアウトバック"}                      |
+------------+---------------------------------------------------------------------------+
|      3     |{"zh-CN":"路虎 揽胜","ja-JP":"ランドローバーレンジローバー"}                   |
+------------+---------------------------------------------------------------------------+
|      4     |{"en-US":"BMW X5"}                                                         |
+------------+---------------------------------------------------------------------------+

How can I create a elasticsearch index for products table which supports search in i18n?如何为支持 i18n 搜索的products表创建 elasticsearch 索引?

Thanks a lot!非常感谢!

I can see you have the language identifier in your database as en-us , zh-cn which means before storing the title, you know the language of product, than you can simply use the multi-field and can add a new language sub-field for all the available languages in Elasticsearch.我可以看到您的数据库中的语言标识符为en-uszh-cn这意味着在存储标题之前,您知道产品的语言,而不是您可以简单地使用多字段并添加新的语言子- Elasticsearch 中所有可用语言的字段。

You can have a look at all the current supported languages in Elasticsearch and add all the sub-fields in beginning or change the mapping and add a new language sub-field as you get it in your system.您可以查看Elasticsearch 中所有当前支持的语言,并在开头添加所有子字段或更改映射并在系统中添加新的语言子字段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM