0
votes

I want to use synonyms for my search. So I defined a 'synonyms' fieldType in schema.xml.

<fieldType name="foo" class="solr.TextField" positionIncrementGap="100">
  <analyzer type="query">
    <tokenizer class="solr.StandardTokenizerFactory" />
    <filter class="solr.ManagedSynonymFilterFactory" managed="german" />
    <!--<filter class="solr.SynonymGraphFilterFactory" ignoreCase="true" expand="true" managed="german" />-->
    <filter class="solr.LowerCaseFilterFactory"/>
  </analyzer>
</fieldType>

This fieldType is used by a field:

<field name="test" type="foo" required="true" />

Now I am adding synonyms to Solr (6.5.1) via the API, like this I can keep the synonyms updated via a web backend, e.g.

curl -X PUT -H 'Content-type:application/json' --data-binary '["mad","angry","insane"]}' "http://localhost:8983/solr/core/schema/analysis/synonyms/german"

That's pretty cool and adding works as expected. I can see them through:

http://localhost:8983/solr/core/schema/analysis/synonyms/german

My problem is that this needs re-indexing, before they work, even though I am using query-time instead of index-time.

Is it possible to manage the synonyms "on the fly" without re-indexing?

My impression is, yes, as long as I am using query-time, but this is not working for me, so I guess I did something wrong?

Do I have to use synonyms.txt over the API to achive this?

But the text file would not as easy as the API to maintain the synonyms I guess?

Thanks for reading and best regards

1

1 Answers

2
votes

As described in documentation https://cwiki.apache.org/confluence/display/solr/Managed+Resources#ManagedResources-ApplyingChanges:

Changes made to managed resources via this REST API are not applied to the active Solr components until the Solr collection (or Solr core in single server mode) is reloaded.

So you don't need to reindex data to see new synonyms in query-time. You just need to reload core with https://cwiki.apache.org/confluence/display/solr/CoreAdmin+API#CoreAdminAPI-RELOAD or https://cwiki.apache.org/confluence/display/solr/Collections+API#CollectionsAPI-RELOAD:ReloadaCollection

Take a note that you should reload all cores in your solr setup. If you have two cores and reload only one, you will see changes only on one reloaded core.