File tree 2 files changed +19
-0
lines changed
main/java/org/springframework/data/elasticsearch/core
test/java/org/springframework/data/elasticsearch/core/routing
2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 79
79
* @author Peter-Josef Meisch
80
80
* @author Roman Puchkovskiy
81
81
* @author Subhobrata Dey
82
+ * @author Steven Pearce
83
+ * @author Anton Naydenov
82
84
*/
83
85
public abstract class AbstractElasticsearchTemplate implements ElasticsearchOperations , ApplicationContextAware {
84
86
@@ -116,6 +118,7 @@ private AbstractElasticsearchTemplate copy() {
116
118
}
117
119
118
120
copy .setRoutingResolver (routingResolver );
121
+ copy .setRefreshPolicy (refreshPolicy );
119
122
120
123
return copy ;
121
124
}
Original file line number Diff line number Diff line change 41
41
42
42
/**
43
43
* @author Peter-Josef Meisch
44
+ * @author Anton Naydenov
44
45
*/
45
46
@ SuppressWarnings ("ConstantConditions" )
46
47
@ SpringIntegrationTest
@@ -118,6 +119,21 @@ void shouldStoreDataWithDifferentRoutingAndGetTheRoutingInTheSearchResult() {
118
119
assertThat (searchHits .getSearchHit (0 ).getRouting ()).isEqualTo (ID_2 );
119
120
}
120
121
122
+ @ Test
123
+ void shouldCreateACopyOfTheClientWithRefreshPolicy () {
124
+ //given
125
+ AbstractElasticsearchTemplate sourceTemplate = (AbstractElasticsearchTemplate ) operations ;
126
+ SimpleElasticsearchMappingContext mappingContext = new SimpleElasticsearchMappingContext ();
127
+ DefaultRoutingResolver defaultRoutingResolver = new DefaultRoutingResolver (mappingContext );
128
+
129
+ //when
130
+ ElasticsearchOperations operationsCopy = this .operations .withRouting (defaultRoutingResolver );
131
+ AbstractElasticsearchTemplate copyTemplate = (AbstractElasticsearchTemplate ) operationsCopy ;
132
+
133
+ //then
134
+ assertThat (sourceTemplate .getRefreshPolicy ()).isEqualTo (copyTemplate .getRefreshPolicy ());
135
+ }
136
+
121
137
@ Document (indexName = INDEX )
122
138
@ Setting (shards = 5 )
123
139
@ Routing ("routing" )
You can’t perform that action at this time.
0 commit comments