Navanshu
Navanshu

Reputation: 11

How to load file "synonyms.txt" present on remote server using solr?

<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>

Here file "synonyms.txt" is present in current directory . How to load this file if it's location is on remote server not on local machine ?

Upvotes: 1

Views: 1257

Answers (2)

Ashraful Islam
Ashraful Islam

Reputation: 12840

You can't load resource from remote. Instead you can http post request to put synonyms to your solr server with ManagedSynonymFilterFactory

This featured introduced in Solr 4.8.0

How to Use :

First you have to declare your filter like below

<filter class="solr.ManagedSynonymFilterFactory" managed="english"/>

You can post Synonyms to solr with the below curl request :

curl -X PUT -H 'Content-type:application/json' --data-binary '{"mad":["angry","upset"]}' "http://solr_ip:8983/solr/collection_name/schema/analysis/synonyms/english"

Here change solr_ip and collection_name with yours. and i am putting word synonyms for mad is angry,upset

And you can check your synonyms by a get request.

http://solr_ip:8983/solr/collection_name/schema/analysis/synonyms/english

For more info : https://cwiki.apache.org/confluence/display/solr/Managed+Resources

Upvotes: 1

sven.windisch
sven.windisch

Reputation: 442

Unfortunately, you can't just type in an URL because the ResourceLoader of the SynonymFilterFactory uses a FilesystemResourceLoader.

Thus said, you could still point Solr to anything that looks and behaves like a file, e.g. an NFS-mounted directory or even a locally synced Dropbox folder.

Upvotes: 0

Related Questions