Skip to content

Commit c0e2bb6

Browse files
committed
[DE-382] inverted index (#457)
* updated fulltext index deprecation note * added AnalyzerFeature.offset * InvertedIndexOptions * create InvertedIndex sync * get InvertedIndex sync * test fixes * async API (cherry picked from commit 7280906)
1 parent bc1c431 commit c0e2bb6

22 files changed

+1186
-15
lines changed

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

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,9 @@ <T> MultiDocumentEntity<DocumentDeleteEntity<T>> deleteDocuments(
579579

580580
/**
581581
* Fetches information about the index with the given {@code id} and returns it.
582+
* <br/>
583+
* <b>Note:</b> inverted indexes are not returned by this method. Use
584+
* {@link ArangoCollection#getInvertedIndex(String)} instead.
582585
*
583586
* @param id The index-handle
584587
* @return information about the index
@@ -587,6 +590,17 @@ <T> MultiDocumentEntity<DocumentDeleteEntity<T>> deleteDocuments(
587590
*/
588591
IndexEntity getIndex(String id);
589592

593+
/**
594+
* Fetches information about the inverted index with the given {@code id} and returns it.
595+
*
596+
* @param id The index-handle
597+
* @return information about the index
598+
* @throws ArangoDBException
599+
* @see <a href="https://www.arangodb.com/docs/stable/http/indexes-working-with.html#read-index">API Documentation</a>
600+
* @since ArangoDB 3.10
601+
*/
602+
InvertedIndexEntity getInvertedIndex(String id) throws ArangoDBException;
603+
590604
/**
591605
* Deletes the index with the given {@code id} from the collection.
592606
*
@@ -655,7 +669,7 @@ <T> MultiDocumentEntity<DocumentDeleteEntity<T>> deleteDocuments(
655669
* @return information about the index
656670
* @see <a href="https://www.arangodb.com/docs/stable/http/indexes-fulltext.html#create-fulltext-index">API
657671
* Documentation</a>
658-
* @deprecated since ArangoDB 3.10, use ArangoSearch view instead.
672+
* @deprecated since ArangoDB 3.10, use ArangoSearch or Inverted indexes instead.
659673
*/
660674
@Deprecated
661675
IndexEntity ensureFulltextIndex(Iterable<String> fields, FulltextIndexOptions options);
@@ -683,8 +697,22 @@ <T> MultiDocumentEntity<DocumentDeleteEntity<T>> deleteDocuments(
683697
*/
684698
IndexEntity ensureZKDIndex(Iterable<String> fields, ZKDIndexOptions options);
685699

700+
/**
701+
* Creates an inverted index for the collection, if it does not already exist.
702+
*
703+
* @param options index creation options
704+
* @return information about the index
705+
* @throws ArangoDBException
706+
* @see <a href="https://www.arangodb.com/docs/stable/http/indexes-inverted.html">API Documentation</a>
707+
* @since ArangoDB 3.10
708+
*/
709+
InvertedIndexEntity ensureInvertedIndex(InvertedIndexOptions options) throws ArangoDBException;
710+
686711
/**
687712
* Fetches a list of all indexes on this collection.
713+
* <br/>
714+
* <b>Note:</b> inverted indexes are not returned by this method. Use
715+
* {@link ArangoCollection#getInvertedIndexes()} instead.
688716
*
689717
* @return information about the indexes
690718
* @see <a href=
@@ -693,6 +721,18 @@ <T> MultiDocumentEntity<DocumentDeleteEntity<T>> deleteDocuments(
693721
*/
694722
Collection<IndexEntity> getIndexes();
695723

724+
/**
725+
* Fetches a list of all inverted indexes on this collection.
726+
*
727+
* @return information about the indexes
728+
* @throws ArangoDBException
729+
* @see <a href=
730+
* "https://www.arangodb.com/docs/stable/http/indexes-working-with.html#read-all-indexes-of-a-collection">API
731+
* Documentation</a>
732+
* @since ArangoDB 3.10
733+
*/
734+
Collection<InvertedIndexEntity> getInvertedIndexes() throws ArangoDBException;
735+
696736
/**
697737
* Checks whether the collection exists
698738
*

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

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,9 @@ <T> CompletableFuture<MultiDocumentEntity<DocumentDeleteEntity<T>>> deleteDocume
619619

620620
/**
621621
* Returns an index
622+
* <br/>
623+
* <b>Note:</b> inverted indexes are not returned by this method. Use
624+
* {@link ArangoCollectionAsync#getInvertedIndex(String)} instead.
622625
*
623626
* @param id The index-handle
624627
* @return information about the index
@@ -627,6 +630,16 @@ <T> CompletableFuture<MultiDocumentEntity<DocumentDeleteEntity<T>>> deleteDocume
627630
*/
628631
CompletableFuture<IndexEntity> getIndex(final String id);
629632

633+
/**
634+
* Returns an inverted index
635+
*
636+
* @param id The index-handle
637+
* @return information about the index
638+
* @see <a href="https://www.arangodb.com/docs/stable/http/indexes-working-with.html#read-index">API Documentation</a>
639+
* @since ArangoDB 3.10
640+
*/
641+
CompletableFuture<InvertedIndexEntity> getInvertedIndex(String id);
642+
630643
/**
631644
* Deletes an index
632645
*
@@ -699,7 +712,7 @@ CompletableFuture<IndexEntity> ensurePersistentIndex(
699712
* @return information about the index
700713
* @see <a href="https://www.arangodb.com/docs/stable/http/indexes-fulltext.html#create-fulltext-index">API
701714
* Documentation</a>
702-
* @deprecated since ArangoDB 3.10, use ArangoSearch view instead.
715+
* @deprecated since ArangoDB 3.10, use ArangoSearch or Inverted indexes instead.
703716
*/
704717
@Deprecated
705718
CompletableFuture<IndexEntity> ensureFulltextIndex(
@@ -729,8 +742,21 @@ CompletableFuture<IndexEntity> ensureFulltextIndex(
729742
*/
730743
CompletableFuture<IndexEntity> ensureZKDIndex(final Iterable<String> fields, final ZKDIndexOptions options);
731744

745+
/**
746+
* Creates an inverted index for the collection, if it does not already exist.
747+
*
748+
* @param options index creation options
749+
* @return information about the index
750+
* @see <a href="https://www.arangodb.com/docs/stable/http/indexes-inverted.html">API Documentation</a>
751+
* @since ArangoDB 3.10
752+
*/
753+
CompletableFuture<InvertedIndexEntity> ensureInvertedIndex(InvertedIndexOptions options);
754+
732755
/**
733756
* Returns all indexes of the collection
757+
* <br/>
758+
* <b>Note:</b> inverted indexes are not returned by this method. Use
759+
* {@link ArangoCollectionAsync#getInvertedIndexes()} instead.
734760
*
735761
* @return information about the indexes
736762
* @see <a href=
@@ -739,6 +765,17 @@ CompletableFuture<IndexEntity> ensureFulltextIndex(
739765
*/
740766
CompletableFuture<Collection<IndexEntity>> getIndexes();
741767

768+
/**
769+
* Fetches a list of all inverted indexes on this collection.
770+
*
771+
* @return information about the indexes
772+
* @see <a href=
773+
* "https://www.arangodb.com/docs/stable/http/indexes-working-with.html#read-all-indexes-of-a-collection">API
774+
* Documentation</a>
775+
* @since ArangoDB 3.10
776+
*/
777+
CompletableFuture<Collection<InvertedIndexEntity>> getInvertedIndexes();
778+
742779
/**
743780
* Checks whether the collection exists
744781
*

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,11 @@ public CompletableFuture<IndexEntity> getIndex(final String id) {
351351
return executor.execute(getIndexRequest(id), IndexEntity.class);
352352
}
353353

354+
@Override
355+
public CompletableFuture<InvertedIndexEntity> getInvertedIndex(String id) {
356+
return executor.execute(getIndexRequest(id), InvertedIndexEntity.class);
357+
}
358+
354359
@Override
355360
public CompletableFuture<String> deleteIndex(final String id) {
356361
return executor.execute(deleteIndexRequest(id), deleteIndexResponseDeserializer());
@@ -404,11 +409,21 @@ public CompletableFuture<IndexEntity> ensureZKDIndex(
404409
return executor.execute(createZKDIndexRequest(fields, options), IndexEntity.class);
405410
}
406411

412+
@Override
413+
public CompletableFuture<InvertedIndexEntity> ensureInvertedIndex(InvertedIndexOptions options) {
414+
return executor.execute(createInvertedIndexRequest(options), InvertedIndexEntity.class);
415+
}
416+
407417
@Override
408418
public CompletableFuture<Collection<IndexEntity>> getIndexes() {
409419
return executor.execute(getIndexesRequest(), getIndexesResponseDeserializer());
410420
}
411421

422+
@Override
423+
public CompletableFuture<Collection<InvertedIndexEntity>> getInvertedIndexes() {
424+
return executor.execute(getIndexesRequest(), getInvertedIndexesResponseDeserializer());
425+
}
426+
412427
@Override
413428
public CompletableFuture<Boolean> exists() {
414429
return getInfo().thenApply(Objects::nonNull).exceptionally(Objects::isNull);

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import com.arangodb.internal.net.HostHandler;
3232
import com.arangodb.internal.net.HostResolver;
3333
import com.arangodb.internal.serde.InternalSerde;
34+
import com.arangodb.internal.serde.SerdeUtils;
3435
import com.arangodb.internal.velocystream.VstCommunication;
3536
import com.arangodb.internal.velocystream.VstCommunicationSync;
3637
import com.arangodb.internal.velocystream.VstProtocol;
@@ -39,7 +40,6 @@
3940
import com.arangodb.model.LogOptions;
4041
import com.arangodb.model.UserCreateOptions;
4142
import com.arangodb.model.UserUpdateOptions;
42-
import com.arangodb.velocypack.Type;
4343
import com.arangodb.velocystream.Request;
4444
import com.arangodb.velocystream.Response;
4545
import org.slf4j.Logger;
@@ -237,8 +237,7 @@ public CompletableFuture<LogLevelEntity> setLogLevel(final LogLevelEntity entity
237237

238238
@Override
239239
public CompletableFuture<Collection<QueryOptimizerRule>> getQueryOptimizerRules() {
240-
return executor.execute(getQueryOptimizerRulesRequest(), new Type<Collection<QueryOptimizerRule>>() {
241-
}.getType());
240+
return executor.execute(getQueryOptimizerRulesRequest(), SerdeUtils.constructListType(QueryOptimizerRule.class));
242241
}
243242

244243
}

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

Lines changed: 7 additions & 2 deletions
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
}
Lines changed: 154 additions & 0 deletions
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 {
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)