{"id":21994376,"url":"https://github.com/codelibs/elasticsearch-analysis-synonym","last_synced_at":"2025-10-08T18:43:30.215Z","repository":{"id":24469706,"uuid":"27873338","full_name":"codelibs/elasticsearch-analysis-synonym","owner":"codelibs","description":"NGramSynonymTokenizer for Elasticsearch","archived":false,"fork":false,"pushed_at":"2021-12-14T20:32:07.000Z","size":124,"stargazers_count":24,"open_issues_count":6,"forks_count":8,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-05-28T01:07:18.201Z","etag":null,"topics":["elasticsearch","elasticsearch-plugin","synonyms"],"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":"2014-12-11T13:43:43.000Z","updated_at":"2023-03-10T03:18:38.000Z","dependencies_parsed_at":"2022-08-18T01:01:05.299Z","dependency_job_id":null,"html_url":"https://github.com/codelibs/elasticsearch-analysis-synonym","commit_stats":null,"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"purl":"pkg:github/codelibs/elasticsearch-analysis-synonym","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codelibs%2Felasticsearch-analysis-synonym","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codelibs%2Felasticsearch-analysis-synonym/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codelibs%2Felasticsearch-analysis-synonym/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codelibs%2Felasticsearch-analysis-synonym/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codelibs","download_url":"https://codeload.github.com/codelibs/elasticsearch-analysis-synonym/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codelibs%2Felasticsearch-analysis-synonym/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261335062,"owners_count":23143464,"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","synonyms"],"created_at":"2024-11-29T21:08:40.487Z","updated_at":"2025-10-08T18:43:25.178Z","avatar_url":"https://github.com/codelibs.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Elasticsearch Analysis Synonym\n=======================\n\n## Overview\n\nElasticsearch Analysis Synonym Plugin provides NGramSynonymTokenizer.\nFor more details, see [LUCENE-5252](https://issues.apache.org/jira/browse/LUCENE-5252 \"LUCENE-5252\").\n\n## Version\n\n[Versions in Maven Repository](http://central.maven.org/maven2/org/codelibs/elasticsearch-analysis-synonym/)\n\n### Issues/Questions\n\nPlease file an [issue](https://github.com/codelibs/elasticsearch-analysis-synonym/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-analysis-synonym:5.3.0\n\n### For 2.x\n\n    $ $ES_HOME/bin/plugin install org.codelibs/elasticsearch-analysis-synonym/2.4.0\n\n## Getting Started\n\n### Create synonym.txt File\n\nFirst of all, you need to create a synonym dictionary file, synonym.txt in $ES\\_CONF(ex. /etc/elasticsearch).\n(The following content is just a sample...)\n\n    $ cat /etc/elasticsearch/synonym.txt\n    あ,かき,さしす,たちつて,なにぬねの\n\n### Create Index\n\nNGramSynonymTokenizer is defined as \"ngram\\_synonym\" type.\nCreating an index with \"ngram\\_synonym\" is below:\n\n    $ curl -XPUT localhost:9200/sample?pretty -d '\n    {\n      \"settings\":{\n        \"index\":{\n          \"analysis\":{\n            \"tokenizer\":{\n              \"2gram_synonym\":{\n                \"type\":\"ngram_synonym\",\n                \"n\":\"2\",\n                \"synonyms_path\":\"synonym.txt\"\n              }\n            },\n            \"analyzer\":{\n              \"2gram_synonym_analyzer\":{\n                \"type\":\"custom\",\n                \"tokenizer\":\"2gram_synonym\"\n              }\n            }\n          }\n        }\n      },\n      \"mappings\":{\n        \"item\":{\n          \"properties\":{\n            \"id\":{\n              \"type\":\"string\",\n              \"index\":\"not_analyzed\"\n            },\n            \"msg\":{\n              \"type\":\"string\",\n              \"analyzer\":\"2gram_synonym_analyzer\"\n            }\n          }\n        }\n      }\n    }'\n\nand then insert data:\n\n    $ curl -XPOST localhost:9200/sample/item/1 -d '\n    {\n      \"id\":\"1\",\n      \"msg\":\"あいうえお\"\n    }'\n\n### Check Search Results\n\nTry searching...\n\n    $ curl -XPOST \"http://localhost:9200/sample/_search\" -d '\n    {\n       \"query\": {\n          \"match_phrase\": {\n             \"msg\": \"あ\"\n          }\n       }\n    }'\n\n    $ curl -XPOST \"http://localhost:9200/sample/_search\" -d '\n    {\n       \"query\": {\n          \"match_phrase\": {\n             \"msg\": \"あい\"\n          }\n       }\n    }'\n\n    $ curl -XPOST \"http://localhost:9200/sample/_search\" -d '\n    {\n       \"query\": {\n          \"match_phrase\": {\n             \"msg\": \"かき\"\n          }\n       }\n    }'\n\n    $ curl -XPOST \"http://localhost:9200/sample/_search\" -d '\n    {\n       \"query\": {\n          \"match_phrase\": {\n             \"msg\": \"かきい\"\n          }\n       }\n    }'\n\n### Reload synonyms_path File Dynamically\n\nTo add \"dynamic\\_reload\" property as true, NGramSynonymTokenizer reloads synonyms\\_path file on the fly(actually, it's reload on reset() method call).\nIf you want to change an interval time to check a file timestamp, add \"reload\\_interval\".\n\n    $ curl -XPUT localhost:9200/sample?pretty -d '\n    {\n      \"settings\":{\n        \"index\":{\n          \"analysis\":{\n            \"tokenizer\":{\n              \"2gram_synonym\":{\n                \"type\":\"ngram_synonym\",\n                \"n\":\"2\",\n                \"synonyms_path\":\"synonym.txt\",\n                \"dynamic_reload\":true,\n                \"reload_interval\":\"10s\"\n              }\n            },\n    ...\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodelibs%2Felasticsearch-analysis-synonym","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodelibs%2Felasticsearch-analysis-synonym","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodelibs%2Felasticsearch-analysis-synonym/lists"}