Rafal, thanks for a quick reply! I think I already understood how to do this for a new index. The issue is how do you do this for an existing index? Am I supposed to do smth like this?:
curl -XPOST 'http://localhost:9200/my_twitter_river/settings/' -d ' { "analysis" : { "filter" : { "synonym" : { "type" : "synonym", "synonyms_path" : "synonym.txt" } } } } ' Also, some posts seem to indicate that if I run a query on _all fileds, this won't be taken into account anyway. Is this true? Thanks! On Monday, December 30, 2013 1:51:59 PM UTC+1, Rafał Kuć wrote: > > Hello! > > This is a part of the mappings you send to Elasticsearch, for example > during index creation. The synonyms_path property is relative to the config > directory. So if your file is synonym.txt, it should go to $ES_HOME/config > and you could send the following command to create an index: > > curl -XPOST 'localhost:9200/test' -d ' > { > "settings": { > "index" : { > "analysis" : { > "analyzer" : { > "synonym" : { > "tokenizer" : "whitespace", > "filter" : ["synonym"] > } > }, > "filter" : { > "synonym" : { > "type" : "synonym", > "synonyms_path" : "synonym.txt" > } > } > } > } > }, > "mappings" : { > "test" : { > "properties" : { > "name" : { "type" : "string", "index" : "analyzed", "analyzer" : > "synonym" } > } > } > } > }' > > My synonym.txt file had the following contents: > aaa=>bbb > > Now to test it, just run the following command: > curl -XGET > 'localhost:9200/test/_analyze?analyzer=synonym&text=aaa+test&pretty=true' > > And you should get something like this: > { > "tokens" : [ { > "token" : "bbb", > "start_offset" : 0, > "end_offset" : 3, > "type" : "SYNONYM", > "position" : 1 > }, { > "token" : "test", > "start_offset" : 4, > "end_offset" : 8, > "type" : "word", > "position" : 2 > } ] > } > > So, as you can see it works. Can you check if it works for you? > > > > > > *-- Regards, Rafał Kuć Performance Monitoring * Log Analytics * Search > Analytics Solr & Elasticsearch Support * *http://sematext.com/ > > > > Hi, > > I'm trying to install a synonym token filter for an existing index and > having a hard time understanding how this should be done. I've created a > synonym.txt file, but I can't understand how to implement the config > described in the doc: > http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/analysis-synonym-tokenfilter.html. > > Is this a file? If so, should it go into the config directory? Or is this > supposed to be PUT via curl? None of the things I've tried so far worked. > Please help! > > Thanks a lot, > Alex > -- > 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 [email protected] <javascript:>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elasticsearch/d89026ea-aad1-4537-8dac-8ea18a0c6b13%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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/9d9c0a4f-75ad-41a5-96a2-479514c1646c%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
