Skip to content

[DE-382] inverted index #457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion src/main/java/com/arangodb/ArangoCollection.java
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,9 @@ <T> MultiDocumentEntity<DocumentDeleteEntity<T>> deleteDocuments(

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

/**
* Fetches information about the inverted index with the given {@code id} and returns it.
*
* @param id The index-handle
* @return information about the index
* @throws ArangoDBException
* @see <a href="https://www.arangodb.com/docs/stable/http/indexes-working-with.html#read-index">API Documentation</a>
* @since ArangoDB 3.10
*/
InvertedIndexEntity getInvertedIndex(String id) throws ArangoDBException;

/**
* Deletes the index with the given {@code id} from the collection.
*
Expand Down Expand Up @@ -519,7 +533,7 @@ <T> MultiDocumentEntity<DocumentDeleteEntity<T>> deleteDocuments(
* @throws ArangoDBException
* @see <a href="https://www.arangodb.com/docs/stable/http/indexes-fulltext.html#create-fulltext-index">API
* Documentation</a>
* @deprecated since ArangoDB 3.10, use ArangoSearch view instead.
* @deprecated since ArangoDB 3.10, use ArangoSearch or Inverted indexes instead.
*/
@Deprecated
IndexEntity ensureFulltextIndex(Iterable<String> fields, FulltextIndexOptions options) throws ArangoDBException;
Expand Down Expand Up @@ -549,8 +563,22 @@ <T> MultiDocumentEntity<DocumentDeleteEntity<T>> deleteDocuments(
*/
IndexEntity ensureZKDIndex(Iterable<String> fields, ZKDIndexOptions options) throws ArangoDBException;

/**
* Creates an inverted index for the collection, if it does not already exist.
*
* @param options index creation options
* @return information about the index
* @throws ArangoDBException
* @see <a href="https://www.arangodb.com/docs/stable/http/indexes-inverted.html">API Documentation</a>
* @since ArangoDB 3.10
*/
InvertedIndexEntity ensureInvertedIndex(InvertedIndexOptions options) throws ArangoDBException;

/**
* Fetches a list of all indexes on this collection.
* <br/>
* <b>Note:</b> inverted indexes are not returned by this method. Use
* {@link ArangoCollection#getInvertedIndexes()} instead.
*
* @return information about the indexes
* @throws ArangoDBException
Expand All @@ -560,6 +588,18 @@ <T> MultiDocumentEntity<DocumentDeleteEntity<T>> deleteDocuments(
*/
Collection<IndexEntity> getIndexes() throws ArangoDBException;

/**
* Fetches a list of all inverted indexes on this collection.
*
* @return information about the indexes
* @throws ArangoDBException
* @see <a href=
* "https://www.arangodb.com/docs/stable/http/indexes-working-with.html#read-all-indexes-of-a-collection">API
* Documentation</a>
* @since ArangoDB 3.10
*/
Collection<InvertedIndexEntity> getInvertedIndexes() throws ArangoDBException;

/**
* Checks whether the collection exists
*
Expand Down
45 changes: 40 additions & 5 deletions src/main/java/com/arangodb/async/ArangoCollectionAsync.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

package com.arangodb.async;

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

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

/**
* Reads multiple documents
Expand Down Expand Up @@ -410,13 +408,26 @@ <T> CompletableFuture<MultiDocumentEntity<DocumentDeleteEntity<T>>> deleteDocume

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

/**
* Returns an inverted index
*
* @param id The index-handle
* @return information about the index
* @see <a href="https://www.arangodb.com/docs/stable/http/indexes-working-with.html#read-index">API Documentation</a>
* @since ArangoDB 3.10
*/
CompletableFuture<InvertedIndexEntity> getInvertedIndex(String id);

/**
* Deletes an index
*
Expand Down Expand Up @@ -487,7 +498,7 @@ CompletableFuture<IndexEntity> ensurePersistentIndex(
* @return information about the index
* @see <a href="https://www.arangodb.com/docs/stable/http/indexes-fulltext.html#create-fulltext-index">API
* Documentation</a>
* @deprecated since ArangoDB 3.10, use ArangoSearch view instead.
* @deprecated since ArangoDB 3.10, use ArangoSearch or Inverted indexes instead.
*/
@Deprecated
CompletableFuture<IndexEntity> ensureFulltextIndex(
Expand Down Expand Up @@ -517,8 +528,21 @@ CompletableFuture<IndexEntity> ensureFulltextIndex(
*/
CompletableFuture<IndexEntity> ensureZKDIndex(final Iterable<String> fields, final ZKDIndexOptions options);

/**
* Creates an inverted index for the collection, if it does not already exist.
*
* @param options index creation options
* @return information about the index
* @see <a href="https://www.arangodb.com/docs/stable/http/indexes-inverted.html">API Documentation</a>
* @since ArangoDB 3.10
*/
CompletableFuture<InvertedIndexEntity> ensureInvertedIndex(InvertedIndexOptions options);

/**
* Returns all indexes of the collection
* <br/>
* <b>Note:</b> inverted indexes are not returned by this method. Use
* {@link ArangoCollectionAsync#getInvertedIndexes()} instead.
*
* @return information about the indexes
* @see <a href=
Expand All @@ -527,6 +551,17 @@ CompletableFuture<IndexEntity> ensureFulltextIndex(
*/
CompletableFuture<Collection<IndexEntity>> getIndexes();

/**
* Fetches a list of all inverted indexes on this collection.
*
* @return information about the indexes
* @see <a href=
* "https://www.arangodb.com/docs/stable/http/indexes-working-with.html#read-all-indexes-of-a-collection">API
* Documentation</a>
* @since ArangoDB 3.10
*/
CompletableFuture<Collection<InvertedIndexEntity>> getInvertedIndexes();

/**
* Checks whether the collection exists
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ public CompletableFuture<IndexEntity> getIndex(final String id) {
return executor.execute(getIndexRequest(id), IndexEntity.class);
}

@Override
public CompletableFuture<InvertedIndexEntity> getInvertedIndex(String id) {
return executor.execute(getIndexRequest(id), InvertedIndexEntity.class);
}

@Override
public CompletableFuture<String> deleteIndex(final String id) {
return executor.execute(deleteIndexRequest(id), deleteIndexResponseDeserializer());
Expand Down Expand Up @@ -311,11 +316,21 @@ public CompletableFuture<IndexEntity> ensureZKDIndex(
return executor.execute(createZKDIndexRequest(fields, options), IndexEntity.class);
}

@Override
public CompletableFuture<InvertedIndexEntity> ensureInvertedIndex(InvertedIndexOptions options) {
return executor.execute(createInvertedIndexRequest(options), InvertedIndexEntity.class);
}

@Override
public CompletableFuture<Collection<IndexEntity>> getIndexes() {
return executor.execute(getIndexesRequest(), getIndexesResponseDeserializer());
}

@Override
public CompletableFuture<Collection<InvertedIndexEntity>> getInvertedIndexes() {
return executor.execute(getIndexesRequest(), getInvertedIndexesResponseDeserializer());
}

@Override
public CompletableFuture<Boolean> exists() {
return getInfo().thenApply(Objects::nonNull).exceptionally(Objects::isNull);
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/com/arangodb/entity/IndexType.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public enum IndexType {
geo2,

/**
* @deprecated since ArangoDB 3.10, use ArangoSearch view instead.
* @deprecated since ArangoDB 3.10, use ArangoSearch or Inverted indexes instead.
*/
@Deprecated
fulltext,
Expand All @@ -50,5 +50,10 @@ public enum IndexType {

ttl,

zkd
zkd,

/**
* @since ArangoDB 3.10
*/
inverted
}
154 changes: 154 additions & 0 deletions src/main/java/com/arangodb/entity/InvertedIndexEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
/*
* DISCLAIMER
*
* Copyright 2016 ArangoDB GmbH, Cologne, Germany
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Copyright holder is ArangoDB GmbH, Cologne, Germany
*/

package com.arangodb.entity;

import com.arangodb.entity.arangosearch.AnalyzerFeature;
import com.arangodb.entity.arangosearch.ConsolidationPolicy;
import com.arangodb.entity.arangosearch.StoredValue;

import java.util.Collection;
import java.util.Set;

/**
* TODO: add documentation
*
* @author Michele Rastelli
* @see <a href="https://www.arangodb.com/docs/stable/http/indexes-inverted.html">API Documentation</a>
* @since ArangoDB 3.10
*/
public class InvertedIndexEntity implements Entity {

private String id;
private Boolean isNewlyCreated;
private Boolean unique;
private Boolean sparse;
private Long version;
private Integer code;
private IndexType type;
private String name;
private Collection<InvertedIndexField> fields;
private Boolean searchField;
private Collection<StoredValue> storedValues;
private InvertedIndexPrimarySort primarySort;
private String analyzer;
private Set<AnalyzerFeature> features;
private Boolean includeAllFields;
private Boolean trackListPositions;
private Long cleanupIntervalStep;
private Long commitIntervalMsec;
private Long consolidationIntervalMsec;
private ConsolidationPolicy consolidationPolicy;
private Long writebufferIdle;
private Long writebufferActive;
private Long writebufferSizeMax;

public String getId() {
return id;
}

public Boolean getIsNewlyCreated() {
return isNewlyCreated;
}

public Boolean getUnique() {
return unique;
}

public Boolean getSparse() {
return sparse;
}

public Long getVersion() {
return version;
}

public Integer getCode() {
return code;
}

public IndexType getType() {
return type;
}

public String getName() {
return name;
}

public Collection<InvertedIndexField> getFields() {
return fields;
}

public Boolean getSearchField() {
return searchField;
}

public Collection<StoredValue> getStoredValues() {
return storedValues;
}

public InvertedIndexPrimarySort getPrimarySort() {
return primarySort;
}

public String getAnalyzer() {
return analyzer;
}

public Set<AnalyzerFeature> getFeatures() {
return features;
}

public Boolean getIncludeAllFields() {
return includeAllFields;
}

public Boolean getTrackListPositions() {
return trackListPositions;
}

public Long getCleanupIntervalStep() {
return cleanupIntervalStep;
}

public Long getCommitIntervalMsec() {
return commitIntervalMsec;
}

public Long getConsolidationIntervalMsec() {
return consolidationIntervalMsec;
}

public ConsolidationPolicy getConsolidationPolicy() {
return consolidationPolicy;
}

public Long getWritebufferIdle() {
return writebufferIdle;
}

public Long getWritebufferActive() {
return writebufferActive;
}

public Long getWritebufferSizeMax() {
return writebufferSizeMax;
}
}
Loading