strategy
@ConfigDocDefault("write-sync")
Optional<String> strategy()
The synchronization strategy to use when indexing automatically.
Defines how complete indexing should be before resuming the application thread
after a database transaction is committed.
[WARNING]
====
Indexing synchronization is only relevant when coordination is disabled (which is the default).
With the xref:hibernate-search-orm-elasticsearch.adoc#coordination[`outbox-polling` coordination strategy],
indexing happens in background threads and is always asynchronous;
the behavior is equivalent to the `write-sync` synchronization strategy.
====
Available values:
[cols=5]
!===
.2+h!Strategy
.2+h!Throughput
3+^h!Guarantees when the application thread resumes
h!Changes applied
h!Changes safe from crash/power loss
h!Changes visible on search
!async
!Best
^!icon:times[role=red]
^!icon:times[role=red]
^!icon:times[role=red]
!write-sync (**default**)
!Medium
^!icon:check[role=lime]
^!icon:check[role=lime]
^!icon:times[role=red]
!read-sync
!Medium to worst
^!icon:check[role=lime]
^!icon:times[role=red]
^!icon:check[role=lime]
!sync
!Worst
^!icon:check[role=lime]
^!icon:check[role=lime]
^!icon:check[role=lime]
!===
This property also accepts a xref:hibernate-search-orm-elasticsearch.adoc#bean-reference-note-anchor[bean reference]
to a custom implementations of `AutomaticIndexingSynchronizationStrategy`.
See
link:{hibernate-search-doc-prefix}#mapper-orm-indexing-automatic-synchronization[this section of the reference documentation]
for more information.
[NOTE]
====
Instead of setting this configuration property,
you can simply annotate your custom `AutomaticIndexingSynchronizationStrategy` implementation with `@SearchExtension`
and leave the configuration property unset: Hibernate Search will use the annotated implementation automatically.
If this configuration property is set, it takes precedence over any `@SearchExtension` annotation.
====