{"id":19081502,"url":"https://github.com/intracto/elastic-synonym","last_synced_at":"2026-06-26T09:31:17.162Z","repository":{"id":56992799,"uuid":"406753706","full_name":"Intracto/elastic-synonym","owner":"Intracto","description":null,"archived":false,"fork":false,"pushed_at":"2022-03-22T20:45:00.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-02-04T16:49:03.078Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Intracto.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":"2021-09-15T12:25:11.000Z","updated_at":"2022-03-22T20:45:03.000Z","dependencies_parsed_at":"2022-08-21T10:00:11.721Z","dependency_job_id":null,"html_url":"https://github.com/Intracto/elastic-synonym","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Intracto%2Felastic-synonym","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Intracto%2Felastic-synonym/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Intracto%2Felastic-synonym/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Intracto%2Felastic-synonym/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Intracto","download_url":"https://codeload.github.com/Intracto/elastic-synonym/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240131746,"owners_count":19752727,"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":[],"created_at":"2024-11-09T02:36:35.611Z","updated_at":"2026-05-22T17:30:20.774Z","avatar_url":"https://github.com/Intracto.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Intracto Elastic Synonym\n============\n\nThis library reads/writes elasticsearch synonyms and converts them into an array of editable objects.\nA refresh action can be called whenever you want to make the updated synonyms available for your users.\n\nSee `intracto/elastic-synonym-bundle` for a plug-and-play implementation for symfony 4.4+ using bootstrap.\n\nNote: make sure you're using a query that supports analyzing, like the regular match filter (example below).\n\nAdditional requirements:\n* Elasticsearch 7.3+\n* Synonym filter must be applied to the search analyzer. It won't work for index analyzers\n\nInstallation\n============\n\n```console\n$ composer require intracto/elastic_synonym\n```\n\nSynonym file on filesystem\n==========================\nThere are a few limitations we need to work around:\n* Elasticsearch will *only* read wherever the current config file is located (usually `/etc/elasticsearch`)\n* Our webuser on the filesystem will propably have not the permissions to write to the desired directory.\n\nThis is why we choose to work with a symlink.\nThis can also be implemented as you want, but here is a working example using vagrant:\n```console\n$ mkdir /vagrant/.elastic-synonym\n$ touch /vagrant/.elastic-synonym/synonyms.txt # name the file anyway you want\n\n$ sudo ln -s /vagrant/.elastic-synonym /etc/elasticsearch/analytics\n```\n\n\nSynonym filter in elastic\n=========================\nAdd the following filter under `settings.analysis.filter`:\n```php\n'my_synonyms' =\u003e [ // a name for your filter\n    'type' =\u003e 'synonym_graph',\n    'synonyms_path' =\u003e 'analytics/synonyms.txt', // This needs to be the path inside /etc/elastic.\n    'updateable' =\u003e true, // *must* be true\n],\n```\n\nIf you want to add it to your default search analyzer, add the following settings under `settings.analysis.analyzer`:\n```php\n'default_search' =\u003e [\n    // ..\n    'filter' =\u003e [/*'..', */'my_synonyms'],\n],\n```\n\nA simple example (assuming you're using defaults and added the filter to your default_search):\n```php\n$body['query']['bool']['should'][] = ['match' =\u003e ['description' =\u003e [\n    'query' =\u003e 'this is an example',\n    'fuzziness' =\u003e 'AUTO',\n    'operator' =\u003e 'OR',\n]]];\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintracto%2Felastic-synonym","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fintracto%2Felastic-synonym","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintracto%2Felastic-synonym/lists"}