Skip to content

Commit d8c2830

Browse files
authored
typed analyzers (#334)
* typed analyzers * resolved pending TODOs * API deprecations and changelog upd
1 parent 4b250c6 commit d8c2830

23 files changed

+1320
-1
lines changed

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
66

77
## [Unreleased]
88

9+
- typed ArangoSearch analyzers
910
- updated dependecies
1011
- bugfix asynchronous shutdown
1112

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

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import com.arangodb.entity.*;
2424
import com.arangodb.entity.arangosearch.AnalyzerEntity;
25+
import com.arangodb.entity.arangosearch.analyzer.SearchAnalyzer;
2526
import com.arangodb.model.*;
2627
import com.arangodb.model.arangosearch.AnalyzerDeleteOptions;
2728
import com.arangodb.model.arangosearch.ArangoSearchCreateOptions;
@@ -729,9 +730,21 @@ <V, E> TraversalEntity<V, E> executeTraversal(Class<V> vertexClass, Class<E> edg
729730
* @throws ArangoDBException
730731
* @see <a href="https://www.arangodb.com/docs/stable/http/analyzers.html">API Documentation</a>
731732
* @since ArangoDB 3.5.0
733+
* @deprecated use {@link this#createSearchAnalyzer(SearchAnalyzer)}}
732734
*/
733735
AnalyzerEntity createAnalyzer(AnalyzerEntity options) throws ArangoDBException;
734736

737+
/**
738+
* Creates an Analyzer
739+
*
740+
* @param analyzer SearchAnalyzer
741+
* @return the created Analyzer
742+
* @throws ArangoDBException
743+
* @see <a href="https://www.arangodb.com/docs/stable/http/analyzers.html">API Documentation</a>
744+
* @since ArangoDB 3.5.0
745+
*/
746+
SearchAnalyzer createSearchAnalyzer(SearchAnalyzer analyzer) throws ArangoDBException;
747+
735748
/**
736749
* Gets information about an Analyzer
737750
*
@@ -740,26 +753,50 @@ <V, E> TraversalEntity<V, E> executeTraversal(Class<V> vertexClass, Class<E> edg
740753
* @throws ArangoDBException
741754
* @see <a href="https://www.arangodb.com/docs/stable/http/analyzers.html">API Documentation</a>
742755
* @since ArangoDB 3.5.0
756+
* @deprecated use {@link this#getSearchAnalyzer(String)}}
743757
*/
744758
AnalyzerEntity getAnalyzer(String name) throws ArangoDBException;
745759

760+
/**
761+
* Gets information about an Analyzer
762+
*
763+
* @param name of the Analyzer without database prefix
764+
* @return information about an Analyzer
765+
* @throws ArangoDBException
766+
* @see <a href="https://www.arangodb.com/docs/stable/http/analyzers.html">API Documentation</a>
767+
* @since ArangoDB 3.5.0
768+
*/
769+
SearchAnalyzer getSearchAnalyzer(String name) throws ArangoDBException;
770+
746771
/**
747772
* Retrieves all analyzers definitions.
748773
*
749774
* @return collection of all analyzers definitions
750775
* @throws ArangoDBException
751776
* @see <a href="https://www.arangodb.com/docs/stable/http/analyzers.html">API Documentation</a>
752777
* @since ArangoDB 3.5.0
778+
* @deprecated use {@link this#getSearchAnalyzers()}
753779
*/
754780
Collection<AnalyzerEntity> getAnalyzers() throws ArangoDBException;
755781

782+
/**
783+
* Retrieves all analyzers definitions.
784+
*
785+
* @return collection of all analyzers definitions
786+
* @throws ArangoDBException
787+
* @see <a href="https://www.arangodb.com/docs/stable/http/analyzers.html">API Documentation</a>
788+
* @since ArangoDB 3.5.0
789+
*/
790+
Collection<SearchAnalyzer> getSearchAnalyzers() throws ArangoDBException;
791+
756792
/**
757793
* Deletes an Analyzer
758794
*
759795
* @param name of the Analyzer without database prefix
760796
* @throws ArangoDBException
761797
* @see <a href="https://www.arangodb.com/docs/stable/http/analyzers.html">API Documentation</a>
762798
* @since ArangoDB 3.5.0
799+
* @deprecated use {@link this#deleteSearchAnalyzer(String)}}}
763800
*/
764801
void deleteAnalyzer(String name) throws ArangoDBException;
765802

@@ -771,7 +808,29 @@ <V, E> TraversalEntity<V, E> executeTraversal(Class<V> vertexClass, Class<E> edg
771808
* @throws ArangoDBException
772809
* @see <a href="https://www.arangodb.com/docs/stable/http/analyzers.html">API Documentation</a>
773810
* @since ArangoDB 3.5.0
811+
* @deprecated use {@link this#deleteSearchAnalyzer(String, AnalyzerDeleteOptions)}}}
774812
*/
775813
void deleteAnalyzer(String name, AnalyzerDeleteOptions options) throws ArangoDBException;
776814

815+
/**
816+
* Deletes an Analyzer
817+
*
818+
* @param name of the Analyzer without database prefix
819+
* @throws ArangoDBException
820+
* @see <a href="https://www.arangodb.com/docs/stable/http/analyzers.html">API Documentation</a>
821+
* @since ArangoDB 3.5.0
822+
*/
823+
void deleteSearchAnalyzer(String name) throws ArangoDBException;
824+
825+
/**
826+
* Deletes an Analyzer
827+
*
828+
* @param name of the Analyzer without database prefix
829+
* @param options AnalyzerDeleteOptions
830+
* @throws ArangoDBException
831+
* @see <a href="https://www.arangodb.com/docs/stable/http/analyzers.html">API Documentation</a>
832+
* @since ArangoDB 3.5.0
833+
*/
834+
void deleteSearchAnalyzer(String name, AnalyzerDeleteOptions options) throws ArangoDBException;
835+
777836
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
/**
2727
* @author Michele Rastelli
28+
* @deprecated use typed analyzers {@link com.arangodb.entity.arangosearch.analyzer}
2829
*/
2930
public class AnalyzerEntity {
3031

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* DISCLAIMER
3+
*
4+
* Copyright 2016 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.entity.arangosearch.analyzer;
22+
23+
24+
import com.arangodb.entity.arangosearch.AnalyzerType;
25+
26+
import java.util.Objects;
27+
28+
/**
29+
* @author Michele Rastelli
30+
*/
31+
public class DelimiterAnalyzer extends SearchAnalyzer {
32+
public DelimiterAnalyzer() {
33+
setType(AnalyzerType.delimiter);
34+
}
35+
36+
private DelimiterAnalyzerProperties properties;
37+
38+
public DelimiterAnalyzerProperties getProperties() {
39+
return properties;
40+
}
41+
42+
public void setProperties(DelimiterAnalyzerProperties properties) {
43+
this.properties = properties;
44+
}
45+
46+
@Override
47+
public boolean equals(Object o) {
48+
if (this == o) return true;
49+
if (o == null || getClass() != o.getClass()) return false;
50+
if (!super.equals(o)) return false;
51+
DelimiterAnalyzer that = (DelimiterAnalyzer) o;
52+
return Objects.equals(properties, that.properties);
53+
}
54+
55+
@Override
56+
public int hashCode() {
57+
return Objects.hash(super.hashCode(), properties);
58+
}
59+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* DISCLAIMER
3+
*
4+
* Copyright 2016 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.entity.arangosearch.analyzer;
22+
23+
24+
import java.util.Objects;
25+
26+
/**
27+
* @author Michele Rastelli
28+
*/
29+
public class DelimiterAnalyzerProperties {
30+
31+
private String delimiter;
32+
33+
public String getDelimiter() {
34+
return delimiter;
35+
}
36+
37+
public void setDelimiter(String delimiter) {
38+
this.delimiter = delimiter;
39+
}
40+
41+
@Override
42+
public boolean equals(Object o) {
43+
if (this == o) return true;
44+
if (o == null || getClass() != o.getClass()) return false;
45+
DelimiterAnalyzerProperties that = (DelimiterAnalyzerProperties) o;
46+
return Objects.equals(delimiter, that.delimiter);
47+
}
48+
49+
@Override
50+
public int hashCode() {
51+
return Objects.hash(delimiter);
52+
}
53+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* DISCLAIMER
3+
*
4+
* Copyright 2016 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.entity.arangosearch.analyzer;
22+
23+
24+
import java.util.Objects;
25+
26+
/**
27+
* @author Michele Rastelli
28+
*/
29+
public class EdgeNgram {
30+
private long min;
31+
private long max;
32+
private boolean preserveOriginal;
33+
34+
public long getMin() {
35+
return min;
36+
}
37+
38+
public void setMin(long min) {
39+
this.min = min;
40+
}
41+
42+
public long getMax() {
43+
return max;
44+
}
45+
46+
public void setMax(long max) {
47+
this.max = max;
48+
}
49+
50+
public boolean isPreserveOriginal() {
51+
return preserveOriginal;
52+
}
53+
54+
public void setPreserveOriginal(boolean preserveOriginal) {
55+
this.preserveOriginal = preserveOriginal;
56+
}
57+
58+
@Override
59+
public boolean equals(Object o) {
60+
if (this == o) return true;
61+
if (o == null || getClass() != o.getClass()) return false;
62+
EdgeNgram edgeNgram = (EdgeNgram) o;
63+
return min == edgeNgram.min &&
64+
max == edgeNgram.max &&
65+
preserveOriginal == edgeNgram.preserveOriginal;
66+
}
67+
68+
@Override
69+
public int hashCode() {
70+
return Objects.hash(min, max, preserveOriginal);
71+
}
72+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* DISCLAIMER
3+
*
4+
* Copyright 2016 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.entity.arangosearch.analyzer;
22+
23+
24+
import com.arangodb.entity.arangosearch.AnalyzerType;
25+
26+
/**
27+
* @author Michele Rastelli
28+
*/
29+
public class IdentityAnalyzer extends SearchAnalyzer {
30+
public IdentityAnalyzer() {
31+
setType(AnalyzerType.identity);
32+
}
33+
34+
@Override
35+
public boolean equals(Object o) {
36+
return super.equals(o);
37+
}
38+
39+
@Override
40+
public int hashCode() {
41+
return super.hashCode();
42+
}
43+
}

0 commit comments

Comments
 (0)