# Get synonyms of existing synonym token filter

**URL:** https://discuss.elastic.co/t/get-synonyms-of-existing-synonym-token-filter/14727
**Category:** Elasticsearch
**Created:** [December 5, 2013, 1:08pm UTC](https://discuss.elastic.co/t/get-synonyms-of-existing-synonym-token-filter/14727 "2013-12-05T13:08:59Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Stefan\_Meiwald](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Stefan\_Meiwald](https://discuss.elastic.co/u/Stefan_Meiwald)
#### Post date: [December 5, 2013, 1:08pm UTC](https://discuss.elastic.co/t/get-synonyms-of-existing-synonym-token-filter/14727/1 "2013-12-05T13:08:59Z")

</div>

Hi,

is there any more efficient way to get the synonyms which are saved in a  
synonym token filter than parsing the \_settings answer of an index?

The settings response look like this as json and I am only interested in  
the actual synonym lines.

- index.analysis.filter.fbl\_synonym1\_filter.synonyms.2: test2, test3
- index.analysis.filter.fbl\_synonym1\_filter.synonyms.1: test1, test2
- index.analysis.filter.fbl\_synonym1\_filter.synonyms.0: -, \_
- 

{

- fbl\_synonym1: {
  - settings: {
    - index.number\_of\_shards: 4
    - index.number\_of\_replicas: 0
    - index.analysis.filter.fbl\_synonym1\_filter.type: synonym
    - index.analysis.filter.fbl\_synonym1\_filter.synonyms.2: test2,test3
    - index.analysis.analyzer.fbl\_synonym1\_analyzer.type: custom
    - index.analysis.analyzer.fbl\_synonym1\_analyzer.tokenizer:  
lowercase
    - index.analysis.filter.fbl\_synonym1\_filter.synonyms.1: test1,test2
    - index.analysis.filter.fbl\_synonym1\_filter.synonyms.0: -, \_
    - index.analysis.analyzer.fbl\_synonym1\_analyzer.filter:  
fbl\_synonym1\_filter
    - index.version.created: 900799
    - index.uuid: 5cqvi4DcROmxiVf4axOi6g  
}  
}

}

A java api solution would be awesome.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/6c55401a-4cd3-4726-ad72-7f1aa1bc21a5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6c55401a-4cd3-4726-ad72-7f1aa1bc21a5%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)
#### Post date: [December 5, 2013, 3:20pm UTC](https://discuss.elastic.co/t/get-synonyms-of-existing-synonym-token-filter/14727/2 "2013-12-05T15:20:35Z")

</div>

The actual filter has no public accessor for the internal synonym map, so  
it is not possible that way. However, you can simply look at its code and  
figure out how it is reading the synonyms and replicate it:

[https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/analysis/SynonymTokenFilterFactory.java#L57-L69](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/analysis/SynonymTokenFilterFactory.java#L57-L69)

The synonyms unit test does not use the yml file, but it is still a good  
place to learn from:

[https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/index/analysis/synonyms/SynonymsAnalysisTest.java](https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/index/analysis/synonyms/SynonymsAnalysisTest.java)

Cheers,

Ivan

--  
Ivan

On Thu, Dec 5, 2013 at 5:08 AM, Stefan Meiwald [st.meiwald@gmail.com](mailto:st.meiwald@gmail.com) wrote:

> Hi,
> 
> is there any more efficient way to get the synonyms which are saved in a  
> synonym token filter than parsing the \_settings answer of an index?
> 
> The settings response look like this as json and I am only interested in  
> the actual synonym lines.
> 
> - index.analysis.filter.fbl\_synonym1\_filter.synonyms.2: test2, test3
> - index.analysis.filter.fbl\_synonym1\_filter.synonyms.1: test1, test2
> - index.analysis.filter.fbl\_synonym1\_filter.synonyms.0: -, \_
> - 
> 
> {
> 
> - fbl\_synonym1: {
> - settings: {
> - index.number\_of\_shards: 4
> - index.number\_of\_replicas: 0
> - index.analysis.filter.fbl\_synonym1\_filter.type: synonym
> - index.analysis.filter.fbl\_synonym1\_filter.synonyms.2: test2,test3
> - index.analysis.analyzer.fbl\_synonym1\_analyzer.type: custom
> - index.analysis.analyzer.fbl\_synonym1\_analyzer.tokenizer:  
> lowercase
> - index.analysis.filter.fbl\_synonym1\_filter.synonyms.1: test1,test2
> - index.analysis.filter.fbl\_synonym1\_filter.synonyms.0: -, \_
> - index.analysis.analyzer.fbl\_synonym1\_analyzer.filter:  
> fbl\_synonym1\_filter
> - index.version.created: 900799
> - index.uuid: 5cqvi4DcROmxiVf4axOi6g  
> }  
> }
> 
> }
> 
> A java api solution would be awesome.
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/6c55401a-4cd3-4726-ad72-7f1aa1bc21a5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6c55401a-4cd3-4726-ad72-7f1aa1bc21a5%40googlegroups.com)  
> .  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQBKr9hOfbb-7y-sdqP0XY2DtqhS8a81i9MUe2xLP0mZEA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQBKr9hOfbb-7y-sdqP0XY2DtqhS8a81i9MUe2xLP0mZEA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 2:03am UTC](https://discuss.elastic.co/t/get-synonyms-of-existing-synonym-token-filter/14727/3 "2017-07-06T02:03:04Z")

</div>


