Skip to content

Commit 59e2640

Browse files
committed
InvertedIndexOptions
1 parent b1a7af3 commit 59e2640

File tree

2 files changed

+293
-1
lines changed

2 files changed

+293
-1
lines changed

src/main/java/com/arangodb/entity/IndexType.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,10 @@ public enum IndexType {
5050

5151
ttl,
5252

53-
zkd
53+
zkd,
54+
55+
/**
56+
* @since ArangoDB 3.10
57+
*/
58+
inverted
5459
}
Lines changed: 287 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,287 @@
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.model;
22+
23+
import com.arangodb.entity.IndexType;
24+
import com.arangodb.entity.arangosearch.*;
25+
26+
import java.util.*;
27+
28+
/**
29+
* TODO: document, see https://github.com/arangodb/docs/pull/1109
30+
*
31+
* @author Michele Rastelli
32+
* @see <a href="https://www.arangodb.com/docs/stable/http/indexes-inverted.html">API Documentation</a>
33+
* @since ArangoDB 3.10
34+
*/
35+
public class InvertedIndexOptions extends IndexOptions<InvertedIndexOptions> {
36+
37+
protected final IndexType type = IndexType.inverted;
38+
private Integer parallelism;
39+
private PrimarySort primarySort;
40+
private final Collection<StoredValue> storedValues = new ArrayList<>();
41+
private String analyzer;
42+
private final Collection<AnalyzerFeature> features = new ArrayList<>();
43+
private Boolean includeAllFields;
44+
private Boolean trackListPositions;
45+
private Boolean searchField;
46+
private final Collection<InvertedIndexField> fields = new ArrayList<>();
47+
48+
public InvertedIndexOptions() {
49+
super();
50+
}
51+
52+
@Override
53+
protected InvertedIndexOptions getThis() {
54+
return this;
55+
}
56+
57+
protected IndexType getType() {
58+
return type;
59+
}
60+
61+
public Integer getParallelism() {
62+
return parallelism;
63+
}
64+
65+
public InvertedIndexOptions parallelism(Integer parallelism) {
66+
this.parallelism = parallelism;
67+
return this;
68+
}
69+
70+
public PrimarySort getPrimarySort() {
71+
return primarySort;
72+
}
73+
74+
public InvertedIndexOptions primarySort(PrimarySort primarySort) {
75+
this.primarySort = primarySort;
76+
return this;
77+
}
78+
79+
public Collection<StoredValue> getStoredValues() {
80+
return storedValues;
81+
}
82+
83+
public InvertedIndexOptions storedValues(StoredValue... storedValues) {
84+
Collections.addAll(this.storedValues, storedValues);
85+
return this;
86+
}
87+
88+
public String getAnalyzer() {
89+
return analyzer;
90+
}
91+
92+
public InvertedIndexOptions analyzer(String analyzer) {
93+
this.analyzer = analyzer;
94+
return this;
95+
}
96+
97+
public Collection<AnalyzerFeature> getFeatures() {
98+
return features;
99+
}
100+
101+
public InvertedIndexOptions features(AnalyzerFeature... features) {
102+
Collections.addAll(this.features, features);
103+
return this;
104+
}
105+
106+
public Boolean getIncludeAllFields() {
107+
return includeAllFields;
108+
}
109+
110+
public InvertedIndexOptions includeAllFields(Boolean includeAllFields) {
111+
this.includeAllFields = includeAllFields;
112+
return this;
113+
}
114+
115+
public Boolean getTrackListPositions() {
116+
return trackListPositions;
117+
}
118+
119+
public InvertedIndexOptions trackListPositions(Boolean trackListPositions) {
120+
this.trackListPositions = trackListPositions;
121+
return this;
122+
}
123+
124+
public Boolean getSearchField() {
125+
return searchField;
126+
}
127+
128+
public InvertedIndexOptions searchField(Boolean searchField) {
129+
this.searchField = searchField;
130+
return this;
131+
}
132+
133+
public Collection<InvertedIndexField> getFields() {
134+
return fields;
135+
}
136+
137+
public InvertedIndexOptions fields(InvertedIndexField... fields) {
138+
Collections.addAll(this.fields, fields);
139+
return this;
140+
}
141+
142+
public static class PrimarySort {
143+
private final List<Field> fields = new ArrayList<>();
144+
private ArangoSearchCompression compression;
145+
146+
public List<Field> getFields() {
147+
return fields;
148+
}
149+
150+
public PrimarySort fields(Field... fields) {
151+
Collections.addAll(this.fields, fields);
152+
return this;
153+
}
154+
155+
public ArangoSearchCompression getCompression() {
156+
return compression;
157+
}
158+
159+
public PrimarySort compression(ArangoSearchCompression compression) {
160+
this.compression = compression;
161+
return this;
162+
}
163+
164+
@Override
165+
public boolean equals(Object o) {
166+
if (this == o) return true;
167+
if (o == null || getClass() != o.getClass()) return false;
168+
PrimarySort that = (PrimarySort) o;
169+
return Objects.equals(fields, that.fields) && compression == that.compression;
170+
}
171+
172+
@Override
173+
public int hashCode() {
174+
return Objects.hash(fields, compression);
175+
}
176+
177+
public static class Field {
178+
private final String field;
179+
private final Direction direction;
180+
181+
public Field(String field, Direction direction) {
182+
this.field = field;
183+
this.direction = direction;
184+
}
185+
186+
@Override
187+
public boolean equals(Object o) {
188+
if (this == o) return true;
189+
if (o == null || getClass() != o.getClass()) return false;
190+
Field field1 = (Field) o;
191+
return Objects.equals(field, field1.field) && direction == field1.direction;
192+
}
193+
194+
@Override
195+
public int hashCode() {
196+
return Objects.hash(field, direction);
197+
}
198+
199+
public enum Direction {
200+
asc,
201+
desc
202+
}
203+
204+
}
205+
206+
}
207+
208+
public static class InvertedIndexField {
209+
private String name;
210+
private String analyzer;
211+
private Boolean includeAllFields;
212+
private Boolean searchField;
213+
private Boolean trackListPositions;
214+
private final Collection<AnalyzerFeature> features = new ArrayList<>();
215+
216+
// TODO: nested
217+
// private final Collection<?> nested;
218+
219+
public String getName() {
220+
return name;
221+
}
222+
223+
public InvertedIndexField name(String name) {
224+
this.name = name;
225+
return this;
226+
}
227+
228+
public String getAnalyzer() {
229+
return analyzer;
230+
}
231+
232+
public InvertedIndexField analyzer(String analyzer) {
233+
this.analyzer = analyzer;
234+
return this;
235+
}
236+
237+
public Boolean getIncludeAllFields() {
238+
return includeAllFields;
239+
}
240+
241+
public InvertedIndexField includeAllFields(Boolean includeAllFields) {
242+
this.includeAllFields = includeAllFields;
243+
return this;
244+
}
245+
246+
public Boolean getSearchField() {
247+
return searchField;
248+
}
249+
250+
public InvertedIndexField searchField(Boolean searchField) {
251+
this.searchField = searchField;
252+
return this;
253+
}
254+
255+
public Boolean getTrackListPositions() {
256+
return trackListPositions;
257+
}
258+
259+
public InvertedIndexField trackListPositions(Boolean trackListPositions) {
260+
this.trackListPositions = trackListPositions;
261+
return this;
262+
}
263+
264+
public Collection<AnalyzerFeature> getFeatures() {
265+
return features;
266+
}
267+
268+
public InvertedIndexField features(AnalyzerFeature... features) {
269+
Collections.addAll(this.features, features);
270+
return this;
271+
}
272+
273+
@Override
274+
public boolean equals(Object o) {
275+
if (this == o) return true;
276+
if (o == null || getClass() != o.getClass()) return false;
277+
InvertedIndexField that = (InvertedIndexField) o;
278+
return Objects.equals(name, that.name) && Objects.equals(analyzer, that.analyzer) && Objects.equals(includeAllFields, that.includeAllFields) && Objects.equals(searchField, that.searchField) && Objects.equals(trackListPositions, that.trackListPositions) && Objects.equals(features, that.features);
279+
}
280+
281+
@Override
282+
public int hashCode() {
283+
return Objects.hash(name, analyzer, includeAllFields, searchField, trackListPositions, features);
284+
}
285+
}
286+
287+
}

0 commit comments

Comments
 (0)