We're running a Rails app on Heroku using the Websolr add-on with Sidekiq to queue indexing jobs. This has been working for a long time but now we've tweaked the schema.xml to improve substring matching, etc.
The modified schema.xml is working locally and on CI but the production Rails app isn't picking it up.
Here's a relevant part of the new schema file:
<fieldType name="text_substr" class="solr.TextField" omitNorms="false">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StandardFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.EdgeNGramFilterFactory" minGramSize="3" maxGramSize="10"/>
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
<filter class="solr.PorterStemFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StandardFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.PorterStemFilterFactory"/>
</analyzer>
</fieldType>
<dynamicField name="*_substr" stored="false" type="text_substr" multiValued="true" indexed="true"/>
Here's how that field is being used to index the model:
class Profile < ActiveRecord::Base
searchable do
text :name_similar_match, as: :name_substr do
name
end
end
end
Here's what I've done so far:
- Copy the modified
schema.xmlto Websolr using the configuration tab on their website - Deployed the Rails code which uses the new Solr fields
- Restarted the Heroku worker running Sidekiq by scaling it to 0 and then back up again
When I try to index a Profile in production, the indexing job fails with this error:
RSolr::Error::Http - 400 Bad Request Error: 'ERROR: [doc=Profile 1] unknown field \'name_substr\'','code'=>400
When I've run into this kind of thing in development, restarting Sidekiq as well as Solr fixes it; I've restarted all I can in production though without getting it to work.
One apparent clue is that the production Sidekiq dashboard says it has an uptime of 123 days, despite the Heroku worker being restarted. I've searched the documentation but I can't find any way of actually restarting Sidekiq. If anyone has any idea what's going on then I'd really appreciate some help :)
Websolr support here! That snippet looks fine to me. Note that updating the schema.xml via the Websolr dashboard will automatically deploy the changes to Solr and reload the core(s), so there is no need to restart anything. Pushing up the changes to the Rails app should be enough to start using the new field.
It sounds like everything you have done so far should be working. Mind shooting an email to support -at- websolr.com with your index URL? We'll take a look and make sure nothing else is going on.