{"id":21994354,"url":"https://github.com/codelibs/elasticsearch-langfield","last_synced_at":"2025-04-30T16:47:50.163Z","repository":{"id":45423485,"uuid":"42915542","full_name":"codelibs/elasticsearch-langfield","owner":"codelibs","description":"This plugin provides a useful feature for multi-language","archived":false,"fork":false,"pushed_at":"2022-07-15T19:55:20.000Z","size":1486,"stargazers_count":14,"open_issues_count":7,"forks_count":3,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-30T18:04:08.176Z","etag":null,"topics":["elasticsearch","elasticsearch-plugin"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codelibs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-22T06:23:57.000Z","updated_at":"2025-02-18T20:05:13.000Z","dependencies_parsed_at":"2022-08-03T06:15:30.882Z","dependency_job_id":null,"html_url":"https://github.com/codelibs/elasticsearch-langfield","commit_stats":null,"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codelibs%2Felasticsearch-langfield","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codelibs%2Felasticsearch-langfield/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codelibs%2Felasticsearch-langfield/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codelibs%2Felasticsearch-langfield/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codelibs","download_url":"https://codeload.github.com/codelibs/elasticsearch-langfield/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251747864,"owners_count":21637406,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elasticsearch","elasticsearch-plugin"],"created_at":"2024-11-29T21:08:34.814Z","updated_at":"2025-04-30T16:47:50.139Z","avatar_url":"https://github.com/codelibs.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Elasticsearch LangField Plugin\n=======================\n\n## Overview\n\nLangField Plugin provides a useful feature for multi-language enrivonment.\n\n## Version\n\n[Versions in Maven Repository](http://central.maven.org/maven2/org/codelibs/elasticsearch-langfield/)\n\n### Issues/Questions\n\nPlease file an [issue](https://github.com/codelibs/elasticsearch-langfield/issues \"issue\").\n(Japanese forum is [here](https://github.com/codelibs/codelibs-ja-forum \"here\").)\n\n## Installation\n\n### For 5.x\n\n    $ $ES_HOME/bin/elasticsearch-plugin install org.codelibs:elasticsearch-langfield:5.3.0\n\n### For 2.x\n\n    $ $ES_HOME/bin/plugin install org.codelibs/elasticsearch-langfield/2.4.1\n\n## Getting Started\n\n### Create Index for Multi-Languages\n\nFirst, you need to create index which has fields for multi-languages:\n\n    $ curl -XPUT 'localhost:9200/my_index' -d '\n    {\n      \"mappings\" : {\n        \"my_type\" : {\n          \"properties\" : {\n            \"message\" : {\n              \"type\" : \"langstring\"\n            },\n            \"message_en\" : {\n              \"type\" : \"string\"\n            },\n            \"message_ja\" : {\n              \"type\" : \"string\"\n            }\n          }\n        }\n      },\n      \"settings\" : {\n        \"index\" : {\n          \"number_of_shards\" : \"5\",\n          \"number_of_replicas\" : \"0\"\n        }\n      }\n    }'\n\nwhere message\\_\\* field is for multi-language.\nUsing message field with \"langstring\" type, message\\_\\* fields are stored automaticaly.\nThe above index-setting JSON is just an example. \nIt's better to specify a proper analyzer for message\\_\\* field.\n\n### Insert Documents\n\nInsert 2 documents for English and Japanese:\n\n    $ curl -XPOST \"localhost:9200/my_index/my_type/1\" -d '{\n      \"message\":\"This is a pen.\"\n    }'\n    $ curl -XPOST \"localhost:9200/my_index/my_type/2\" -d '{\n      \"message\":\"これはペンです。\"\n    }'\n\nmessage field detects language and then copy the content of message field to a proper message\\_\\* field.\nCheck the result with exists filter query:\n\n    $ curl -XPOST \"http://localhost:9200/my_index/my_type/_search\" -d'\n    {\n      \"query\": {\n        \"filtered\": {\n          \"query\": {\n            \"match_all\": {}\n          },\n          \"filter\": {\n            \"exists\": {\n              \"field\": \"message_en\"\n            }\n          }\n        }\n      }\n    }'\n    {\n      \"took\": 3,\n      \"timed_out\": false,\n      \"_shards\": {\n        \"total\": 5,\n        \"successful\": 5,\n        \"failed\": 0\n      },\n      \"hits\": {\n        \"total\": 1,\n        \"max_score\": 1,\n        \"hits\": [\n          {\n            \"_index\": \"my_index\",\n            \"_type\": \"my_type\",\n            \"_id\": \"1\",\n            \"_score\": 1,\n            \"_source\": {\n              \"message\": \"This is a pen.\"\n            }\n          }\n        ]\n      }\n    }\n\nNext, check if message_ja field exists:\n\n    $ curl -XPOST \"http://localhost:9200/my_index/my_type/_search\" -d'\n    {\n      \"query\": {\n        \"filtered\": {\n          \"query\": {\n            \"match_all\": {}\n          },\n          \"filter\": {\n            \"exists\": {\n              \"field\": \"message_ja\"\n            }\n          }\n        }\n      }\n    }'\n    {\n      \"took\": 2,\n      \"timed_out\": false,\n      \"_shards\": {\n        \"total\": 5,\n        \"successful\": 5,\n        \"failed\": 0\n      },\n      \"hits\": {\n        \"total\": 1,\n        \"max_score\": 1,\n        \"hits\": [\n          {\n            \"_index\": \"my_index\",\n            \"_type\": \"my_type\",\n            \"_id\": \"2\",\n            \"_score\": 1,\n            \"_source\": {\n              \"message\": \"これはペンです。\"\n            }\n          }\n        ]\n      }\n    }\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodelibs%2Felasticsearch-langfield","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodelibs%2Felasticsearch-langfield","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodelibs%2Felasticsearch-langfield/lists"}