Get synonyms of existing synonym token filter


(Stefan Meiwald) #1

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.
To view this discussion on the web visit 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.


(Ivan Brusic) #2

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

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

Cheers,

Ivan

--
Ivan

On Thu, Dec 5, 2013 at 5:08 AM, Stefan Meiwald 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.
To view this discussion on the web visit
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.

--
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.
To view this discussion on the web visit 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.


(system) #3