Transform some words from the mailing list into a bit of doc for the Reindexer extension
Better than nothing :) Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/eb9ec0db Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/eb9ec0db Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/eb9ec0db Branch: refs/heads/develop Commit: eb9ec0db0aa12f672f451b285b607d3b2aba4d17 Parents: 3f20923 Author: Paul Merlin <[email protected]> Authored: Sun Jun 12 16:36:33 2016 +0200 Committer: Paul Merlin <[email protected]> Committed: Sun Jun 12 16:36:33 2016 +0200 ---------------------------------------------------------------------- extensions/reindexer/dev-status.xml | 2 +- extensions/reindexer/src/docs/reindexer.txt | 38 ++++++++++++++++++-- .../zest/index/reindexer/ReindexerTest.java | 7 +++- 3 files changed, 42 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zest-java/blob/eb9ec0db/extensions/reindexer/dev-status.xml ---------------------------------------------------------------------- diff --git a/extensions/reindexer/dev-status.xml b/extensions/reindexer/dev-status.xml index c5d4441..259bfcf 100644 --- a/extensions/reindexer/dev-status.xml +++ b/extensions/reindexer/dev-status.xml @@ -27,7 +27,7 @@ <codebase>stable</codebase> <!-- none, brief, good, complete --> - <documentation>none</documentation> + <documentation>brief</documentation> <!-- none, some, good, complete --> <unittests>some</unittests> http://git-wip-us.apache.org/repos/asf/zest-java/blob/eb9ec0db/extensions/reindexer/src/docs/reindexer.txt ---------------------------------------------------------------------- diff --git a/extensions/reindexer/src/docs/reindexer.txt b/extensions/reindexer/src/docs/reindexer.txt index 7e8a73b..924eaae 100644 --- a/extensions/reindexer/src/docs/reindexer.txt +++ b/extensions/reindexer/src/docs/reindexer.txt @@ -25,8 +25,40 @@ source=extensions/reindexer/dev-status.xml -------------- -Reindexer - -NOTE: This Extension has no documentation yet. Learn how to contribute in <<community-docs>>. +This extension allows you to trigger a complete indexing of EntityStores into Index/Query systems. include::../../build/docs/buildinfo/artifact.txt[] + +The `Reindexer` is totally under your control and doesn't kick in automatically in any way or form. + +[snippet,java] +---- +source=extensions/reindexer/src/test/java/org/apache/zest/index/reindexer/ReindexerTest.java +tag=assembly +---- + +It will be bound to the `EntityStore` that is Visible, ask for all Entities, by calling +`entityStates()` and forward those to all `StateChangeListeners` that are Visible. + +[snippet,java] +---- +source=extensions/reindexer/src/test/java/org/apache/zest/index/reindexer/ReindexerTest.java +tag=usage +---- + +So, you call `reindex()` on the `Reindexer`. If you have many reindexers, you could call +`reindexAll()` which will locate all reindexers and call `reindex()` +on each. This is useful when there are many modules of entity stores. + +There are two general issues that you need to keep in mind; + +1. Not all entity stores implements `entityStates()`, mostly because the + underlying store doesn't provide a convenient mechanism to iterate + everything. + +2. Unless you first clear all in the Index, deletions will not be + detected, and therefor the index might contain to many entity references in + that case. + +Additionally, reindexing is not really thread safe, so need to bring the +system down while reindexing is happening. http://git-wip-us.apache.org/repos/asf/zest-java/blob/eb9ec0db/extensions/reindexer/src/test/java/org/apache/zest/index/reindexer/ReindexerTest.java ---------------------------------------------------------------------- diff --git a/extensions/reindexer/src/test/java/org/apache/zest/index/reindexer/ReindexerTest.java b/extensions/reindexer/src/test/java/org/apache/zest/index/reindexer/ReindexerTest.java index 5d082bc..9feead5 100644 --- a/extensions/reindexer/src/test/java/org/apache/zest/index/reindexer/ReindexerTest.java +++ b/extensions/reindexer/src/test/java/org/apache/zest/index/reindexer/ReindexerTest.java @@ -63,7 +63,9 @@ public class ReindexerTest new RdfNativeSesameStoreAssembler().assemble( module ); // Reindexer + // START SNIPPET: assembly module.services( ReindexerService.class ); + // END SNIPPET: assembly // Configuration ModuleAssembly config = module.layer().module( "config" ); @@ -110,7 +112,10 @@ public class ReindexerTest // ----> Reindex and assert data - serviceFinder.findService( ReindexerService.class ).get().reindex(); // Reindex + // START SNIPPET: usage + Reindexer reindexer = serviceFinder.findService( Reindexer.class ).get(); + reindexer.reindex(); + // END SNIPPET: usage uow = unitOfWorkFactory.newUnitOfWork();
