Skip to content

Commit 7280906

Browse files
authored
[DE-382] inverted index (#457)
* updated fulltext index deprecation note * added AnalyzerFeature.offset * InvertedIndexOptions * create InvertedIndex sync * get InvertedIndex sync * test fixes * async API
1 parent 62b2d60 commit 7280906

22 files changed

+1182
-69
lines changed

src/main/java/com/arangodb/ArangoCollection.java

+41-1
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,9 @@ <T> MultiDocumentEntity<DocumentDeleteEntity<T>> deleteDocuments(
439439

440440
/**
441441
* Fetches information about the index with the given {@code id} and returns it.
442+
* <br/>
443+
* <b>Note:</b> inverted indexes are not returned by this method. Use
444+
* {@link ArangoCollection#getInvertedIndex(String)} instead.
442445
*
443446
* @param id The index-handle
444447
* @return information about the index
@@ -447,6 +450,17 @@ <T> MultiDocumentEntity<DocumentDeleteEntity<T>> deleteDocuments(
447450
*/
448451
IndexEntity getIndex(String id) throws ArangoDBException;
449452

453+
/**
454+
* Fetches information about the inverted index with the given {@code id} and returns it.
455+
*
456+
* @param id The index-handle
457+
* @return information about the index
458+
* @throws ArangoDBException
459+
* @see <a href="https://www.arangodb.com/docs/stable/http/indexes-working-with.html#read-index">API Documentation</a>
460+
* @since ArangoDB 3.10
461+
*/
462+
InvertedIndexEntity getInvertedIndex(String id) throws ArangoDBException;
463+
450464
/**
451465
* Deletes the index with the given {@code id} from the collection.
452466
*
@@ -519,7 +533,7 @@ <T> MultiDocumentEntity<DocumentDeleteEntity<T>> deleteDocuments(
519533
* @throws ArangoDBException
520534
* @see <a href="https://www.arangodb.com/docs/stable/http/indexes-fulltext.html#create-fulltext-index">API
521535
* Documentation</a>
522-
* @deprecated since ArangoDB 3.10, use ArangoSearch view instead.
536+
* @deprecated since ArangoDB 3.10, use ArangoSearch or Inverted indexes instead.
523537
*/
524538
@Deprecated
525539
IndexEntity ensureFulltextIndex(Iterable<String> fields, FulltextIndexOptions options) throws ArangoDBException;
@@ -549,8 +563,22 @@ <T> MultiDocumentEntity<DocumentDeleteEntity<T>> deleteDocuments(
549563
*/
550564
IndexEntity ensureZKDIndex(Iterable<String> fields, ZKDIndexOptions options) throws ArangoDBException;
551565

566+
/**
567+
* Creates an inverted index for the collection, if it does not already exist.
568+
*
569+
* @param options index creation options
570+
* @return information about the index
571+
* @throws ArangoDBException
572+
* @see <a href="https://www.arangodb.com/docs/stable/http/indexes-inverted.html">API Documentation</a>
573+
* @since ArangoDB 3.10
574+
*/
575+
InvertedIndexEntity ensureInvertedIndex(InvertedIndexOptions options) throws ArangoDBException;
576+
552577
/**
553578
* Fetches a list of all indexes on this collection.
579+
* <br/>
580+
* <b>Note:</b> inverted indexes are not returned by this method. Use
581+
* {@link ArangoCollection#getInvertedIndexes()} instead.
554582
*
555583
* @return information about the indexes
556584
* @throws ArangoDBException
@@ -560,6 +588,18 @@ <T> MultiDocumentEntity<DocumentDeleteEntity<T>> deleteDocuments(
560588
*/
561589
Collection<IndexEntity> getIndexes() throws ArangoDBException;
562590

591+
/**
592+
* Fetches a list of all inverted indexes on this collection.
593+
*
594+
* @return information about the indexes
595+
* @throws ArangoDBException
596+
* @see <a href=
597+
* "https://www.arangodb.com/docs/stable/http/indexes-working-with.html#read-all-indexes-of-a-collection">API
598+
* Documentation</a>
599+
* @since ArangoDB 3.10
600+
*/
601+
Collection<InvertedIndexEntity> getInvertedIndexes() throws ArangoDBException;
602+
563603
/**
564604
* Checks whether the collection exists
565605
*

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

+40-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
package com.arangodb.async;
2222

23-
import com.arangodb.ArangoDBException;
2423
import com.arangodb.ArangoSerializationAccessor;
2524
import com.arangodb.entity.*;
2625
import com.arangodb.model.*;
@@ -145,7 +144,7 @@ CompletableFuture<DocumentImportEntity> importDocuments(
145144
* @see <a href="https://www.arangodb.com/docs/stable/http/document-working-with-documents.html#read-document">API
146145
* Documentation</a>
147146
*/
148-
<T> CompletableFuture<T> getDocument(final String key, final Class<T> type) throws ArangoDBException;
147+
<T> CompletableFuture<T> getDocument(final String key, final Class<T> type);
149148

150149
/**
151150
* Reads a single document
@@ -157,8 +156,7 @@ CompletableFuture<DocumentImportEntity> importDocuments(
157156
* @see <a href="https://www.arangodb.com/docs/stable/http/document-working-with-documents.html#read-document">API
158157
* Documentation</a>
159158
*/
160-
<T> CompletableFuture<T> getDocument(final String key, final Class<T> type, final DocumentReadOptions options)
161-
throws ArangoDBException;
159+
<T> CompletableFuture<T> getDocument(final String key, final Class<T> type, final DocumentReadOptions options);
162160

163161
/**
164162
* Reads multiple documents
@@ -410,13 +408,26 @@ <T> CompletableFuture<MultiDocumentEntity<DocumentDeleteEntity<T>>> deleteDocume
410408

411409
/**
412410
* Returns an index
411+
* <br/>
412+
* <b>Note:</b> inverted indexes are not returned by this method. Use
413+
* {@link ArangoCollectionAsync#getInvertedIndex(String)} instead.
413414
*
414415
* @param id The index-handle
415416
* @return information about the index
416417
* @see <a href="https://www.arangodb.com/docs/stable/http/indexes-working-with.html#read-index">API Documentation</a>
417418
*/
418419
CompletableFuture<IndexEntity> getIndex(final String id);
419420

421+
/**
422+
* Returns an inverted index
423+
*
424+
* @param id The index-handle
425+
* @return information about the index
426+
* @see <a href="https://www.arangodb.com/docs/stable/http/indexes-working-with.html#read-index">API Documentation</a>
427+
* @since ArangoDB 3.10
428+
*/
429+
CompletableFuture<InvertedIndexEntity> getInvertedIndex(String id);
430+
420431
/**
421432
* Deletes an index
422433
*
@@ -487,7 +498,7 @@ CompletableFuture<IndexEntity> ensurePersistentIndex(
487498
* @return information about the index
488499
* @see <a href="https://www.arangodb.com/docs/stable/http/indexes-fulltext.html#create-fulltext-index">API
489500
* Documentation</a>
490-
* @deprecated since ArangoDB 3.10, use ArangoSearch view instead.
501+
* @deprecated since ArangoDB 3.10, use ArangoSearch or Inverted indexes instead.
491502
*/
492503
@Deprecated
493504
CompletableFuture<IndexEntity> ensureFulltextIndex(
@@ -517,8 +528,21 @@ CompletableFuture<IndexEntity> ensureFulltextIndex(
517528
*/
518529
CompletableFuture<IndexEntity> ensureZKDIndex(final Iterable<String> fields, final ZKDIndexOptions options);
519530

531+
/**
532+
* Creates an inverted index for the collection, if it does not already exist.
533+
*
534+
* @param options index creation options
535+
* @return information about the index
536+
* @see <a href="https://www.arangodb.com/docs/stable/http/indexes-inverted.html">API Documentation</a>
537+
* @since ArangoDB 3.10
538+
*/
539+
CompletableFuture<InvertedIndexEntity> ensureInvertedIndex(InvertedIndexOptions options);
540+
520541
/**
521542
* Returns all indexes of the collection
543+
* <br/>
544+
* <b>Note:</b> inverted indexes are not returned by this method. Use
545+
* {@link ArangoCollectionAsync#getInvertedIndexes()} instead.
522546
*
523547
* @return information about the indexes
524548
* @see <a href=
@@ -527,6 +551,17 @@ CompletableFuture<IndexEntity> ensureFulltextIndex(
527551
*/
528552
CompletableFuture<Collection<IndexEntity>> getIndexes();
529553

554+
/**
555+
* Fetches a list of all inverted indexes on this collection.
556+
*
557+
* @return information about the indexes
558+
* @see <a href=
559+
* "https://www.arangodb.com/docs/stable/http/indexes-working-with.html#read-all-indexes-of-a-collection">API
560+
* Documentation</a>
561+
* @since ArangoDB 3.10
562+
*/
563+
CompletableFuture<Collection<InvertedIndexEntity>> getInvertedIndexes();
564+
530565
/**
531566
* Checks whether the collection exists
532567
*

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

+15
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,11 @@ public CompletableFuture<IndexEntity> getIndex(final String id) {
258258
return executor.execute(getIndexRequest(id), IndexEntity.class);
259259
}
260260

261+
@Override
262+
public CompletableFuture<InvertedIndexEntity> getInvertedIndex(String id) {
263+
return executor.execute(getIndexRequest(id), InvertedIndexEntity.class);
264+
}
265+
261266
@Override
262267
public CompletableFuture<String> deleteIndex(final String id) {
263268
return executor.execute(deleteIndexRequest(id), deleteIndexResponseDeserializer());
@@ -311,11 +316,21 @@ public CompletableFuture<IndexEntity> ensureZKDIndex(
311316
return executor.execute(createZKDIndexRequest(fields, options), IndexEntity.class);
312317
}
313318

319+
@Override
320+
public CompletableFuture<InvertedIndexEntity> ensureInvertedIndex(InvertedIndexOptions options) {
321+
return executor.execute(createInvertedIndexRequest(options), InvertedIndexEntity.class);
322+
}
323+
314324
@Override
315325
public CompletableFuture<Collection<IndexEntity>> getIndexes() {
316326
return executor.execute(getIndexesRequest(), getIndexesResponseDeserializer());
317327
}
318328

329+
@Override
330+
public CompletableFuture<Collection<InvertedIndexEntity>> getInvertedIndexes() {
331+
return executor.execute(getIndexesRequest(), getInvertedIndexesResponseDeserializer());
332+
}
333+
319334
@Override
320335
public CompletableFuture<Boolean> exists() {
321336
return getInfo().thenApply(Objects::nonNull).exceptionally(Objects::isNull);

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

+7-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public enum IndexType {
4141
geo2,
4242

4343
/**
44-
* @deprecated since ArangoDB 3.10, use ArangoSearch view instead.
44+
* @deprecated since ArangoDB 3.10, use ArangoSearch or Inverted indexes instead.
4545
*/
4646
@Deprecated
4747
fulltext,
@@ -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
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
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;
22+
23+
import com.arangodb.entity.arangosearch.AnalyzerFeature;
24+
import com.arangodb.entity.arangosearch.ConsolidationPolicy;
25+
import com.arangodb.entity.arangosearch.StoredValue;
26+
27+
import java.util.Collection;
28+
import java.util.Set;
29+
30+
/**
31+
* TODO: add documentation
32+
*
33+
* @author Michele Rastelli
34+
* @see <a href="https://www.arangodb.com/docs/stable/http/indexes-inverted.html">API Documentation</a>
35+
* @since ArangoDB 3.10
36+
*/
37+
public class InvertedIndexEntity implements Entity {
38+
39+
private String id;
40+
private Boolean isNewlyCreated;
41+
private Boolean unique;
42+
private Boolean sparse;
43+
private Long version;
44+
private Integer code;
45+
private IndexType type;
46+
private String name;
47+
private Collection<InvertedIndexField> fields;
48+
private Boolean searchField;
49+
private Collection<StoredValue> storedValues;
50+
private InvertedIndexPrimarySort primarySort;
51+
private String analyzer;
52+
private Set<AnalyzerFeature> features;
53+
private Boolean includeAllFields;
54+
private Boolean trackListPositions;
55+
private Long cleanupIntervalStep;
56+
private Long commitIntervalMsec;
57+
private Long consolidationIntervalMsec;
58+
private ConsolidationPolicy consolidationPolicy;
59+
private Long writebufferIdle;
60+
private Long writebufferActive;
61+
private Long writebufferSizeMax;
62+
63+
public String getId() {
64+
return id;
65+
}
66+
67+
public Boolean getIsNewlyCreated() {
68+
return isNewlyCreated;
69+
}
70+
71+
public Boolean getUnique() {
72+
return unique;
73+
}
74+
75+
public Boolean getSparse() {
76+
return sparse;
77+
}
78+
79+
public Long getVersion() {
80+
return version;
81+
}
82+
83+
public Integer getCode() {
84+
return code;
85+
}
86+
87+
public IndexType getType() {
88+
return type;
89+
}
90+
91+
public String getName() {
92+
return name;
93+
}
94+
95+
public Collection<InvertedIndexField> getFields() {
96+
return fields;
97+
}
98+
99+
public Boolean getSearchField() {
100+
return searchField;
101+
}
102+
103+
public Collection<StoredValue> getStoredValues() {
104+
return storedValues;
105+
}
106+
107+
public InvertedIndexPrimarySort getPrimarySort() {
108+
return primarySort;
109+
}
110+
111+
public String getAnalyzer() {
112+
return analyzer;
113+
}
114+
115+
public Set<AnalyzerFeature> getFeatures() {
116+
return features;
117+
}
118+
119+
public Boolean getIncludeAllFields() {
120+
return includeAllFields;
121+
}
122+
123+
public Boolean getTrackListPositions() {
124+
return trackListPositions;
125+
}
126+
127+
public Long getCleanupIntervalStep() {
128+
return cleanupIntervalStep;
129+
}
130+
131+
public Long getCommitIntervalMsec() {
132+
return commitIntervalMsec;
133+
}
134+
135+
public Long getConsolidationIntervalMsec() {
136+
return consolidationIntervalMsec;
137+
}
138+
139+
public ConsolidationPolicy getConsolidationPolicy() {
140+
return consolidationPolicy;
141+
}
142+
143+
public Long getWritebufferIdle() {
144+
return writebufferIdle;
145+
}
146+
147+
public Long getWritebufferActive() {
148+
return writebufferActive;
149+
}
150+
151+
public Long getWritebufferSizeMax() {
152+
return writebufferSizeMax;
153+
}
154+
}

0 commit comments

Comments
 (0)