Database Bulk Operations

Reindexing

The @Indexed annotation is often added to existing objects. Indexing fields or methods of an existing class does not retroactively index previously persisted data; it only ensures that future data will be indexed.

To reindex existing content, use the Index tool. You can re-index on a single type or all types. If you select all types, all database records, regardless of visibility, will be reindexed. However, if you select a specific type, only visible (published) records will be reindexed.

Records being reindexed are queried for using resolveToReferenceOnly, so any indexed methods which depend on values in referenced (non-embedded) records will not be calculated correctly. You can work around this issue by explicitly resolving the references in the indexed method, or by writing your own reindexing task.

When you start the reindex process, a link appears to the background task that reindexes existing objects. Click the link to monitor the background task.

Note

When importing a new or updated database, Solr will also need to be indexed, which you can do with the Index tool.

../../_images/db-bulk-tool.png

Copy Solr / SQL

Use the Copy tool to copy data from one database to another. The Copy tool is often used when a new MySQL database is added and the Solr database needs to be created. Copying SQL to Solr populates the Solr database with the SQL data.

Another use case is to resynchronize databases that are no longer in sync.

You can copy records from a single type or records of all types. If you select all types, all database records, regardless of visibility, will be copied from the source to the destination. However, if you select a specific type, only visible (published) records will be copied.

If you select Delete before copy, all of the records of the selected type will be deleted from the destination database before beginning the copy. You will probably want to select this if you just loaded a fresh MySQL database, or if you are resynchronizing the databases. If you don’t select this option in these cases, queries could return inconsistent data depending on which database is queried.

The records are saved to the destination database using saveUnsafely, so the save lifecycle will not be triggered. For more information, see Persistence APIs.