Synonym path location for a synonym token filter

Hi,

I am using hibernate search quarkus extension and I am configuring an ElasticSearchAnalysisConfigurer with a token filter like this

context.tokenFilter("synonym")
                .type("synonym")
                .param("synonyms_path", "synonym.txt")

Where should I put the synonym file, as I put it straight under the resources folder but I got a"

no such file exception" when deploying to elk, so I wonder if I have put the file in the correct location.

I didn’t find anything to this in the different documentation, nor Quarkus nor Hibernate Search 6.1

Thanks for helping out

Hi,

See Synonym token filter | Elasticsearch Guide [8.4] | Elastic :

relative to the config location

The path is relative to the config directory of your Elasticsearch install.

I’d recommend inlining the configuration instead, as shown in another example in the same documentation:

          "synonym": {
            "type": "synonym",
            "synonyms": [ "foo, bar => baz" ]
          }

Hi ,

thanks for the swift reply, so if I want to use a file, I can not configure through Hibernate Search but I should apply the configuration straight to Elastic, with the inlining, I can pass through Hibernate Search

So I should do something like this:

  context.tokenFilter("synonym")
                .type("synonym")
                .param("synonyms", "foo, bar => baz")

Yes, you should.

Alternatively, if you really want to use a local file for some reason, you will have to retrieve it yourself, extract each line, and pass the lines as an array.