Skip to content

Commit 7b710f6

Browse files
committed
[DE-384] search-alias views (#461)
* [DE-157] added support to inBackground parameter in ArangoSearch links * ViewType.SEARCH_ALIAS * SearchAlias sync * SearchAlias async * SearchAlias sync tests * disabled ArangoSearchTest for 3.10 cluster * SearchAlias async tests (cherry picked from commit 2d175b0)
1 parent 37c07c2 commit 7b710f6

24 files changed

+1119
-32
lines changed

src/main/java/com/arangodb/ArangoDatabase.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.arangodb.model.*;
2626
import com.arangodb.model.arangosearch.AnalyzerDeleteOptions;
2727
import com.arangodb.model.arangosearch.ArangoSearchCreateOptions;
28+
import com.arangodb.model.arangosearch.SearchAliasCreateOptions;
2829

2930
import javax.annotation.concurrent.ThreadSafe;
3031
import java.util.Collection;
@@ -640,14 +641,23 @@ public interface ArangoDatabase extends ArangoSerdeAccessor {
640641
ArangoView view(String name);
641642

642643
/**
643-
* Returns a {@code ArangoSearch} instance for the given ArangoSearch view name.
644+
* Returns a {@link ArangoSearch} instance for the given view name.
644645
*
645646
* @param name Name of the view
646647
* @return ArangoSearch view handler
647648
* @since ArangoDB 3.4.0
648649
*/
649650
ArangoSearch arangoSearch(String name);
650651

652+
/**
653+
* Returns a {@link SearchAlias} instance for the given view name.
654+
*
655+
* @param name Name of the view
656+
* @return SearchAlias view handler
657+
* @since ArangoDB 3.10
658+
*/
659+
SearchAlias searchAlias(String name);
660+
651661
/**
652662
* Creates a view of the given {@code type}, then returns view information from the server.
653663
*
@@ -670,6 +680,19 @@ public interface ArangoDatabase extends ArangoSerdeAccessor {
670680
*/
671681
ViewEntity createArangoSearch(String name, ArangoSearchCreateOptions options);
672682

683+
/**
684+
* Creates a SearchAlias view with the given {@code options}, then returns view information from the server.
685+
*
686+
* @param name The name of the view
687+
* @param options Additional options, can be null
688+
* @return information about the view
689+
* @throws ArangoDBException
690+
* @see <a href="https://www.arangodb.com/docs/stable/http/views-search-alias.html#create-a-search-alias-view">API
691+
* Documentation</a>
692+
* @since ArangoDB 3.10
693+
*/
694+
ViewEntity createSearchAlias(String name, SearchAliasCreateOptions options) throws ArangoDBException;
695+
673696
/**
674697
* Creates an Analyzer
675698
*

src/main/java/com/arangodb/ArangoSearch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* Interface for operations on ArangoDB view level for ArangoSearch views.
3232
*
3333
* @author Mark Vollmary
34-
* @see <a href="https://www.arangodb.com/docs/stable/http/views.html">View API Documentation</a>
34+
* @see <a href="https://www.arangodb.com/docs/stable/http/views-arangosearch.html">View API Documentation</a>
3535
* @since ArangoDB 3.4.0
3636
*/
3737
@ThreadSafe
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* DISCLAIMER
3+
*
4+
* Copyright 2018 ArangoDB GmbH, Cologne, Germany
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
*/
20+
21+
package com.arangodb;
22+
23+
import com.arangodb.entity.ViewEntity;
24+
import com.arangodb.entity.arangosearch.SearchAliasPropertiesEntity;
25+
import com.arangodb.model.arangosearch.SearchAliasCreateOptions;
26+
import com.arangodb.model.arangosearch.SearchAliasPropertiesOptions;
27+
28+
/**
29+
* Interface for operations on ArangoDB view level for SearchAlias views.
30+
*
31+
* @author Michele Rastelli
32+
* @see <a href="https://www.arangodb.com/docs/stable/http/views-search-alias.html">View API Documentation</a>
33+
* @since ArangoDB 3.10
34+
*/
35+
public interface SearchAlias extends ArangoView {
36+
37+
/**
38+
* Creates a view, then returns view information from the server.
39+
*
40+
* @return information about the view
41+
* @throws ArangoDBException
42+
* @see <a href="https://www.arangodb.com/docs/stable/http/views-search-alias.html#create-a-search-alias-view">API
43+
* Documentation</a>
44+
*/
45+
ViewEntity create() throws ArangoDBException;
46+
47+
/**
48+
* Creates a view with the given {@code options}, then returns view information from the server.
49+
*
50+
* @param options Additional options, can be null
51+
* @return information about the view
52+
* @throws ArangoDBException
53+
* @see <a href="https://www.arangodb.com/docs/stable/http/views-search-alias.html#create-a-search-alias-view">API
54+
* Documentation</a>
55+
*/
56+
ViewEntity create(SearchAliasCreateOptions options) throws ArangoDBException;
57+
58+
/**
59+
* Reads the properties of the specified view.
60+
*
61+
* @return properties of the view
62+
* @throws ArangoDBException
63+
* @see <a href="https://www.arangodb.com/docs/stable/http/views-search-alias.html#read-properties-of-a-view">API
64+
* Documentation</a>
65+
*/
66+
SearchAliasPropertiesEntity getProperties() throws ArangoDBException;
67+
68+
/**
69+
* Partially changes properties of the view.
70+
*
71+
* @param options properties to change
72+
* @return properties of the view
73+
* @throws ArangoDBException
74+
* @see <a href=
75+
* "https://www.arangodb.com/docs/stable/http/views-search-alias.html#partially-changes-properties-of-a-search-alias-view">API
76+
* Documentation</a>
77+
*/
78+
SearchAliasPropertiesEntity updateProperties(SearchAliasPropertiesOptions options) throws ArangoDBException;
79+
80+
/**
81+
* Changes properties of the view.
82+
*
83+
* @param options properties to change
84+
* @return properties of the view
85+
* @throws ArangoDBException
86+
* @see <a href=
87+
* "https://www.arangodb.com/docs/stable/http/views-search-alias.html#changes-properties-of-a-search-alias-view">API
88+
* Documentation</a>
89+
*/
90+
SearchAliasPropertiesEntity replaceProperties(SearchAliasPropertiesOptions options) throws ArangoDBException;
91+
92+
}

src/main/java/com/arangodb/async/ArangoDatabaseAsync.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.arangodb.model.*;
2828
import com.arangodb.model.arangosearch.AnalyzerDeleteOptions;
2929
import com.arangodb.model.arangosearch.ArangoSearchCreateOptions;
30+
import com.arangodb.model.arangosearch.SearchAliasCreateOptions;
3031

3132
import javax.annotation.concurrent.ThreadSafe;
3233
import java.util.Collection;
@@ -670,14 +671,23 @@ CompletableFuture<GraphEntity> createGraph(
670671
ArangoViewAsync view(String name);
671672

672673
/**
673-
* Returns a {@code ArangoSearchAsync} instance for the given ArangoSearch view name.
674+
* Returns a {@link ArangoSearchAsync} instance for the given ArangoSearch view name.
674675
*
675676
* @param name Name of the view
676677
* @return ArangoSearch view handler
677678
* @since ArangoDB 3.4.0
678679
*/
679680
ArangoSearchAsync arangoSearch(String name);
680681

682+
/**
683+
* Returns a {@link SearchAliasAsync} instance for the given view name.
684+
*
685+
* @param name Name of the view
686+
* @return SearchAlias view handler
687+
* @since ArangoDB 3.10
688+
*/
689+
SearchAliasAsync searchAlias(String name);
690+
681691
/**
682692
* Creates a view of the given {@code type}, then returns view information from the server.
683693
*
@@ -700,6 +710,18 @@ CompletableFuture<GraphEntity> createGraph(
700710
*/
701711
CompletableFuture<ViewEntity> createArangoSearch(String name, ArangoSearchCreateOptions options);
702712

713+
/**
714+
* Creates a SearchAlias view with the given {@code options}, then returns view information from the server.
715+
*
716+
* @param name The name of the view
717+
* @param options Additional options, can be null
718+
* @return information about the view
719+
* @see <a href="https://www.arangodb.com/docs/stable/http/views-search-alias.html#create-a-search-alias-view">API
720+
* Documentation</a>
721+
* @since ArangoDB 3.10
722+
*/
723+
CompletableFuture<ViewEntity> createSearchAlias(String name, SearchAliasCreateOptions options);
724+
703725
/**
704726
* Creates an Analyzer
705727
*

src/main/java/com/arangodb/async/ArangoSearchAsync.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* Interface for operations on ArangoDB view level for ArangoSearch views.
3333
*
3434
* @author Mark Vollmary
35-
* @see <a href="https://www.arangodb.com/docs/stable/http/views.html">View API Documentation</a>
35+
* @see <a href="https://www.arangodb.com/docs/stable/http/views-arangosearch.html">View API Documentation</a>
3636
* @since ArangoDB 3.4.0
3737
*/
3838
@ThreadSafe
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* DISCLAIMER
3+
*
4+
* Copyright 2018 ArangoDB GmbH, Cologne, Germany
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
*/
20+
21+
package com.arangodb.async;
22+
23+
import com.arangodb.entity.ViewEntity;
24+
import com.arangodb.entity.arangosearch.SearchAliasPropertiesEntity;
25+
import com.arangodb.model.arangosearch.SearchAliasCreateOptions;
26+
import com.arangodb.model.arangosearch.SearchAliasPropertiesOptions;
27+
28+
import java.util.concurrent.CompletableFuture;
29+
30+
/**
31+
* Interface for operations on ArangoDB view level for SearchAlias views.
32+
*
33+
* @author Michele Rastelli
34+
* @see <a href="https://www.arangodb.com/docs/stable/http/views-search-alias.html">View API Documentation</a>
35+
* @since ArangoDB 3.10
36+
*/
37+
public interface SearchAliasAsync extends ArangoViewAsync {
38+
39+
/**
40+
* Creates a view, then returns view information from the server.
41+
*
42+
* @return information about the view
43+
* @see <a href="https://www.arangodb.com/docs/stable/http/views-search-alias.html#create-a-search-alias-view">API
44+
* Documentation</a>
45+
*/
46+
CompletableFuture<ViewEntity> create();
47+
48+
/**
49+
* Creates a view with the given {@code options}, then returns view information from the server.
50+
*
51+
* @param options Additional options, can be null
52+
* @return information about the view
53+
* @see <a href="https://www.arangodb.com/docs/stable/http/views-search-alias.html#create-a-search-alias-view">API
54+
* Documentation</a>
55+
*/
56+
CompletableFuture<ViewEntity> create(SearchAliasCreateOptions options);
57+
58+
/**
59+
* Reads the properties of the specified view.
60+
*
61+
* @return properties of the view
62+
* @see <a href="https://www.arangodb.com/docs/stable/http/views-search-alias.html#read-properties-of-a-view">API
63+
* Documentation</a>
64+
*/
65+
CompletableFuture<SearchAliasPropertiesEntity> getProperties();
66+
67+
/**
68+
* Partially changes properties of the view.
69+
*
70+
* @param options properties to change
71+
* @return properties of the view
72+
* @see <a href=
73+
* "https://www.arangodb.com/docs/stable/http/views-search-alias.html#partially-changes-properties-of-a-search-alias-view">API
74+
* Documentation</a>
75+
*/
76+
CompletableFuture<SearchAliasPropertiesEntity> updateProperties(SearchAliasPropertiesOptions options);
77+
78+
/**
79+
* Changes properties of the view.
80+
*
81+
* @param options properties to change
82+
* @return properties of the view
83+
* @see <a href=
84+
* "https://www.arangodb.com/docs/stable/http/views-search-alias.html#changes-properties-of-a-search-alias-view">API
85+
* Documentation</a>
86+
*/
87+
CompletableFuture<SearchAliasPropertiesEntity> replaceProperties(SearchAliasPropertiesOptions options);
88+
89+
}

src/main/java/com/arangodb/async/internal/ArangoDatabaseAsyncImpl.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import com.arangodb.model.*;
3535
import com.arangodb.model.arangosearch.AnalyzerDeleteOptions;
3636
import com.arangodb.model.arangosearch.ArangoSearchCreateOptions;
37+
import com.arangodb.model.arangosearch.SearchAliasCreateOptions;
3738
import com.arangodb.velocystream.Request;
3839

3940
import java.util.Collection;
@@ -428,6 +429,11 @@ public ArangoSearchAsync arangoSearch(final String name) {
428429
return new ArangoSearchAsyncImpl(this, name);
429430
}
430431

432+
@Override
433+
public SearchAliasAsync searchAlias(String name) {
434+
return new SearchAliasAsyncImpl(this, name);
435+
}
436+
431437
@Override
432438
public CompletableFuture<ViewEntity> createView(final String name, final ViewType type) {
433439
return executor.execute(createViewRequest(name, type), ViewEntity.class);
@@ -439,6 +445,11 @@ public CompletableFuture<ViewEntity> createArangoSearch(final String name,
439445
return executor.execute(createArangoSearchRequest(name, options), ViewEntity.class);
440446
}
441447

448+
@Override
449+
public CompletableFuture<ViewEntity> createSearchAlias(String name, SearchAliasCreateOptions options) {
450+
return executor.execute(createSearchAliasRequest(name, options), ViewEntity.class);
451+
}
452+
442453
@Override
443454
public CompletableFuture<SearchAnalyzer> createSearchAnalyzer(SearchAnalyzer analyzer) {
444455
return executor.execute(createAnalyzerRequest(analyzer), SearchAnalyzer.class);

0 commit comments

Comments
 (0)