solrsunspotsunspot-railssunspot-solrwebsolr

Sunspot Solr: Is it possible to add a field without reindexing all rows?


On the documentation for Sunspot, it says:

If you make a change to the object's "schema" (code in the searchable block), you must reindex all objects so the changes are reflected in Solr

What happens if this procedure isn't followed?

Specifically, I have a fairly large index on Websolr, and if I just add a boolean field to it without reindexing, what will happen?

I'd like to be able to filter by true values of the boolean field, but I'll never need to filter by false or nil values. Will this work, or must this admonition to reindex always be obeyed?


Solution

  • In your case, if you add the field and do not index the data, it would still work.
    However, the existing data would not have a value for the field.
    Only the new documents inserted would have values for it.
    You can surely filter on the documents based on the values and the existing documents would have a nil value for the field.

    Usually it depends on what you change.

    You would not need a reindex in if you change query time analysis of a field type. A simple restart or core reload would work for you.

    Changes in schema would require a reindex of the collection, if you want the value of the field for all documents.
    If you change a field type, you would need to reindex the content as the analysis done at indexing time on the types of the field would be different.
    If you don't reindex the Query time analysis performed for the field would be different from the one indexed and no matches would be found.