Skip to content

Commit fe0f798

Browse files
committed
[DE-384] added SearchAliasIndex operation type
1 parent 15e791e commit fe0f798

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

src/main/java/com/arangodb/entity/arangosearch/SearchAliasIndex.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,25 @@
77
public class SearchAliasIndex {
88
private final String collection;
99
private final String index;
10+
private final OperationType operation;
1011

12+
/**
13+
* @param collection The name of a collection.
14+
* @param index The name of an inverted index of the collection.
15+
*/
1116
public SearchAliasIndex(String collection, String index) {
17+
this(collection, index, null);
18+
}
19+
20+
/**
21+
* @param collection The name of a collection.
22+
* @param index The name of an inverted index of the collection.
23+
* @param operation Whether to add or remove the index to the stored indexes property of the View. (default "add")
24+
*/
25+
public SearchAliasIndex(String collection, String index, OperationType operation) {
1226
this.collection = collection;
1327
this.index = index;
28+
this.operation = operation;
1429
}
1530

1631
public String getCollection() {
@@ -20,4 +35,12 @@ public String getCollection() {
2035
public String getIndex() {
2136
return index;
2237
}
38+
39+
public OperationType getOperation() {
40+
return operation;
41+
}
42+
43+
public enum OperationType {
44+
add, del
45+
}
2346
}

src/test/java/com/arangodb/ArangoSearchTest.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,23 @@ void createSearchAliasViewWithOptions(ArangoDatabase db) {
228228
void createSearchAliasViewWithIndexesAndGetProperties(ArangoDatabase db) {
229229
assumeTrue(isAtLeastVersion(3, 10));
230230
ArangoCollection col = db.collection(COLL_1);
231-
String idxName = "idx-" + rnd();
231+
String idxName1 = "idx-" + rnd();
232232
col.ensureInvertedIndex(new InvertedIndexOptions()
233-
.name(idxName)
233+
.name(idxName1)
234234
.fields(new InvertedIndexField().name("a" + rnd())));
235+
236+
String idxName2 = "idx-" + rnd();
237+
col.ensureInvertedIndex(new InvertedIndexOptions()
238+
.name(idxName2)
239+
.fields(new InvertedIndexField().name("a" + rnd())));
240+
235241
String viewName = "view-" + rnd();
236242
final SearchAliasCreateOptions options = new SearchAliasCreateOptions()
237-
.indexes(new SearchAliasIndex(COLL_1, idxName));
243+
.indexes(
244+
new SearchAliasIndex(COLL_1, idxName1, SearchAliasIndex.OperationType.add),
245+
new SearchAliasIndex(COLL_1, idxName2, SearchAliasIndex.OperationType.add),
246+
new SearchAliasIndex(COLL_1, idxName2, SearchAliasIndex.OperationType.del)
247+
);
238248
final ViewEntity info = db.searchAlias(viewName).create(options);
239249
assertThat(info).isNotNull();
240250
assertThat(info.getId()).isNotNull();
@@ -249,7 +259,7 @@ void createSearchAliasViewWithIndexesAndGetProperties(ArangoDatabase db) {
249259
assertThat(properties.getIndexes())
250260
.isNotNull()
251261
.isNotEmpty()
252-
.anyMatch(i -> i.getCollection().equals(COLL_1) && i.getIndex().equals(idxName));
262+
.anyMatch(i -> i.getCollection().equals(COLL_1) && i.getIndex().equals(idxName1));
253263
}
254264

255265
@ParameterizedTest(name = "{index}")

0 commit comments

Comments
 (0)