/
SearchIndexingPlan.java
144 lines (133 loc) · 6.81 KB
/
SearchIndexingPlan.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
* Hibernate Search, full-text search for your domain model
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.search.mapper.javabean.work;
/**
* An interface for indexing entities in the context of a session.
* <p>
* This class is stateful: it queues operations internally to apply them when the session is closed.
* <p>
* This contract is not thread-safe.
*/
public interface SearchIndexingPlan {
/**
* Add an entity to the index, assuming that the entity is absent from the index.
* <p>
* Shorthand for {@code add(null, null, entity)}; see {@link #add(Object, String, Object)}.
*
* @param entity The entity to add to the index.
*/
void add(Object entity);
/**
* Add an entity to the index, assuming that the entity is absent from the index.
* <p>
* <strong>Note:</strong> depending on the backend, this may lead to errors or duplicate entries in the index
* if the entity was actually already present in the index before this call.
* When in doubt, you should rather use {@link #addOrUpdate(Object, String, Object)} or {@link #addOrUpdate(Object)}.
*
* @param providedId A value to extract the document ID from.
* Generally the expected value is the entity ID, but a different value may be expected depending on the mapping.
* If {@code null}, Hibernate Search will attempt to extract the ID from the entity.
* @param providedRoutingKey The routing key to route the add request to the appropriate index shard.
* Leave {@code null} if sharding is disabled
* or to have Hibernate Search compute the value through the assigned {@link org.hibernate.search.mapper.pojo.bridge.RoutingBridge}.
* @param entity The entity to add to the index.
*/
void add(Object providedId, String providedRoutingKey, Object entity);
/**
* Update an entity in the index, or add it if it's absent from the index.
* <p>
* Shorthand for {@code addOrUpdate(null, entity)}; see {@link #addOrUpdate(Object, String, Object)}.
*
* @param entity The entity to update in the index.
*/
void addOrUpdate(Object entity);
/**
* Update an entity in the index, or add it if it's absent from the index.
*
* @param providedId A value to extract the document ID from.
* Generally the expected value is the entity ID, but a different value may be expected depending on the mapping.
* If {@code null}, Hibernate Search will attempt to extract the ID from the entity.
* @param providedRoutingKey The routing key to route the addOrUpdate request to the appropriate index shard.
* Leave {@code null} if sharding is disabled
* or to have Hibernate Search compute the value through the assigned {@link org.hibernate.search.mapper.pojo.bridge.RoutingBridge}.
* @param entity The entity to update in the index.
*/
void addOrUpdate(Object providedId, String providedRoutingKey, Object entity);
/**
* Update an entity in the index, or add it if it's absent from the index,
* but try to avoid reindexing if the given dirty paths
* are known not to impact the indexed form of that entity.
* <p>
* Assumes that the entity may already be present in the index.
* <p>
* Shorthand for {@code addOrUpdate(null, entity, dirtyPaths)}; see {@link #addOrUpdate(Object, String, Object, String...)}.
*
* @param entity The entity to update in the index.
* @param dirtyPaths The paths to consider dirty, formatted using the dot-notation
* ("directEntityProperty.nestedPropery").
*/
void addOrUpdate(Object entity, String... dirtyPaths);
/**
* Update an entity in the index, or add it if it's absent from the index,
* but try to avoid reindexing if the given dirty paths
* are known not to impact the indexed form of that entity.
*
* @param providedId A value to extract the document ID from.
* Generally the expected value is the entity ID, but a different value may be expected depending on the mapping.
* If {@code null}, Hibernate Search will attempt to extract the ID from the entity.
* @param providedRoutingKey The routing key to route the addOrUpdate request to the appropriate index shard.
* Leave {@code null} if sharding is disabled
* or to have Hibernate Search compute the value through the assigned {@link org.hibernate.search.mapper.pojo.bridge.RoutingBridge}.
* @param entity The entity to update in the index.
* @param dirtyPaths The paths to consider dirty, formatted using the dot-notation
* ("directEntityProperty.nestedPropery").
*/
void addOrUpdate(Object providedId, String providedRoutingKey, Object entity, String... dirtyPaths);
/**
* Delete an entity from the index.
* <p>
* Shorthand for {@code delete(null, entity)}; see {@link #delete(Object, String, Object)}.
*
* @param entity The entity to delete from the index.
*/
void delete(Object entity);
/**
* Delete an entity from the index.
* <p>
* No effect on the index if the entity is not in the index.
*
* @param providedId A value to extract the document ID from.
* Generally the expected value is the entity ID, but a different value may be expected depending on the mapping.
* If {@code null}, Hibernate Search will attempt to extract the ID from the entity.
* @param providedRoutingKey The routing key to route the addOrUpdate request to the appropriate index shard.
* Leave {@code null} if sharding is disabled
* or to have Hibernate Search compute the value through the assigned {@link org.hibernate.search.mapper.pojo.bridge.RoutingBridge}.
* @param entity The entity to delete from the index.
*/
void delete(Object providedId, String providedRoutingKey, Object entity);
/**
* Delete the entity from the index.
* <p>
* No effect on the index if the entity is not in the index.
* <p>
* On contrary to {@link #delete(Object)},
* if documents embed this entity
* (through {@link org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded} for example),
* these documents will <strong>not</strong> be re-indexed,
* leaving the indexes in an inconsistent state
* until they are re-indexed manually.
*
* @param entityClass The class of the entity to delete from the index.
* @param providedId A value to extract the document ID from.
* Generally the expected value is the entity ID, but a different value may be expected depending on the mapping.
* @param providedRoutingKey The routing key to route the purge request to the appropriate index shard.
* Leave {@code null} if sharding is disabled or if you don't use a custom {@link org.hibernate.search.mapper.pojo.bridge.RoutingBridge}.
* @throws org.hibernate.search.util.common.SearchException If the entity type is not indexed directly
* ({@link org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed}).
*/
void delete(Class<?> entityClass, Object providedId, String providedRoutingKey);
}