Skip to content
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

[DE-797] arangosearch support #301

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* DISCLAIMER
*
* Copyright 2018 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.springframework.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import com.arangodb.entity.arangosearch.ConsolidationType;
import com.arangodb.entity.arangosearch.StoreValuesType;

/**
* @author Mark Vollmary
*
*/
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE })
public @interface ArangoSearch {

/**
* @return The name of the arangosearch view
*/
String value() default "";

/**
* @return Wait at least this many milliseconds between committing index data changes and making them visible to
* queries (default: 60000, to disable use: 0). For the case where there are a lot of inserts/updates, a
* lower value, until commit, will cause the index not to account for them and memory usage would continue
* to grow. For the case where there are a few inserts/updates, a higher value will impact performance and
* waste disk space for each commit call without any added benefits.
*/
long consolidationIntervalMsec() default -1;

/**
* @return Wait at least this many commits between removing unused files in data directory (default: 10, to disable
* use: 0). For the case where the consolidation policies merge segments often (i.e. a lot of
* commit+consolidate), a lower value will cause a lot of disk space to be wasted. For the case where the
* consolidation policies rarely merge segments (i.e. few inserts/deletes), a higher value will impact
* performance without any added benefits.
*/
long cleanupIntervalStep() default -1;

ConsolidationType consolidationType() default ConsolidationType.BYTES_ACCUM;

/**
* @return Select a given segment for "consolidation" if and only if the formula based on type (as defined above)
* evaluates to true, valid value range [0.0, 1.0] (default: 0.85)
*/
double consolidationThreshold() default -1;

/**
* @return Apply the "consolidation" operation if and only if (default: 300): {segmentThreshold} <
* number_of_segments
*/
long consolidationSegmentThreshold() default -1;

/**
* @return The list of analyzers to be used for indexing of string values (default: ["identity"]).
*/
String[] analyzers() default {};

/**
* @return The flag determines whether or not to index all fields on a particular level of depth (default: false).
*/
boolean includeAllFields() default false;

/**
* @return The flag determines whether or not values in a lists should be treated separate (default: false).
*/
boolean trackListPositions() default false;

/**
* @return How should the view track the attribute values, this setting allows for additional value retrieval
* optimizations (default "none").
*/
StoreValuesType storeValues() default StoreValuesType.NONE;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* DISCLAIMER
*
* Copyright 2018 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.springframework.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import com.arangodb.entity.arangosearch.StoreValuesType;

/**
* @author Mark Vollmary
*
*/

@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.FIELD })
public @interface ArangoSearchLinked {

/**
* @return The list of analyzers to be used for indexing of string values (default: ["identity"]).
*/
String[] analyzers() default {};

/**
* @return The flag determines whether or not to index all fields on a particular level of depth (default: false).
*/
boolean includeAllFields() default false;

/**
* @return The flag determines whether or not values in a lists should be treated separate (default: false).
*/
boolean trackListPositions() default false;

/**
* @return How should the view track the attribute values, this setting allows for additional value retrieval
* optimizations (default "none").
*/
StoreValuesType storeValues() default StoreValuesType.NONE;

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;

import com.arangodb.springframework.annotation.ArangoSearch;
import com.arangodb.springframework.annotation.Document;
import com.arangodb.springframework.annotation.Edge;

Expand All @@ -42,8 +43,9 @@
public class ArangoEntityClassScanner {

@SuppressWarnings("unchecked")
private static final Class<? extends Annotation>[] ENTITY_ANNOTATIONS = new Class[] { Document.class, Edge.class };

private static final Class<? extends Annotation>[] ENTITY_ANNOTATIONS = new Class[] { Document.class, Edge.class,
ArangoSearch.class };

@SuppressWarnings("unchecked")
private static final Class<? extends Annotation>[] ADDITIONAL_ANNOTATIONS = new Class[] { TypeAlias.class };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import com.arangodb.model.DocumentReadOptions;
import com.arangodb.model.DocumentReplaceOptions;
import com.arangodb.model.DocumentUpdateOptions;
import com.arangodb.model.arangosearch.ArangoSearchCreateOptions;
import com.arangodb.springframework.core.convert.ArangoConverter;

/**
Expand Down Expand Up @@ -561,6 +562,12 @@ public enum UpsertStrategy {
*/
CollectionOperations collection(String name, CollectionCreateOptions options) throws DataAccessException;

ArangoSearchOperations arangosearch(Class<?> entityClass) throws DataAccessException;

ArangoSearchOperations arangosearch(String name) throws DataAccessException;

ArangoSearchOperations arangosearch(String name, ArangoSearchCreateOptions options) throws DataAccessException;

/**
* Return the operations interface for a user. The user is not created automatically if it does not exists.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* DISCLAIMER
*
* Copyright 2018 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.springframework.core;

import org.springframework.dao.DataAccessException;

import com.arangodb.entity.arangosearch.ArangoSearchPropertiesEntity;
import com.arangodb.model.arangosearch.ArangoSearchPropertiesOptions;

/**
* @author Mark Vollmary
*
*/
public interface ArangoSearchOperations {

/**
* Return the view name
*
* @return view name
*/
String name();

/**
* Deletes the view from the database.
*
* @throws DataAccessException
*/
void drop() throws DataAccessException;

/**
* Reads the properties of the specified view.
*
* @see <a href="https://docs.arangodb.com/current/HTTP/Views/Getting.html#read-properties-of-a-view">API
* Documentation</a>
* @return properties of the view
* @throws DataAccessException
*/
ArangoSearchPropertiesEntity getProperties() throws DataAccessException;

/**
* Partially changes properties of the view.
*
* @see <a href=
* "https://docs.arangodb.com/current/HTTP/Views/ArangoSearch.html#partially-changes-properties-of-an-arangosearch-view">API
* Documentation</a>
* @param options
* properties to change
* @return properties of the view
* @throws DataAccessException
*/
ArangoSearchPropertiesEntity updateProperties(ArangoSearchPropertiesOptions options) throws DataAccessException;

/**
* Changes properties of the view.
*
* @see <a href=
* "https://docs.arangodb.com/current/HTTP/Views/ArangoSearch.html#change-properties-of-an-arangosearch-view">API
* Documentation</a>
* @param options
* properties to change
* @return properties of the view
* @throws DataAccessException
*/
ArangoSearchPropertiesEntity replaceProperties(ArangoSearchPropertiesOptions options) throws DataAccessException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
import org.springframework.data.mapping.IdentifierAccessor;
import org.springframework.data.mapping.PersistentEntity;

import com.arangodb.entity.arangosearch.CollectionLink;
import com.arangodb.model.CollectionCreateOptions;
import com.arangodb.model.arangosearch.ArangoSearchCreateOptions;
import com.arangodb.springframework.annotation.FulltextIndex;
import com.arangodb.springframework.annotation.GeoIndex;
import com.arangodb.springframework.annotation.HashIndex;
Expand All @@ -46,6 +48,12 @@ public interface ArangoPersistentEntity<T>

CollectionCreateOptions getCollectionOptions();

Optional<String> getArangoSearch();

Optional<ArangoSearchCreateOptions> getArangoSearchOptions();

Optional<CollectionLink> getArangoSearchLinkOptions();

Optional<ArangoPersistentProperty> getArangoIdProperty();

Optional<ArangoPersistentProperty> getRevProperty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import org.springframework.data.mapping.PersistentProperty;

import com.arangodb.springframework.annotation.ArangoSearchLinked;
import com.arangodb.springframework.annotation.From;
import com.arangodb.springframework.annotation.FulltextIndexed;
import com.arangodb.springframework.annotation.GeoIndexed;
Expand Down Expand Up @@ -64,4 +65,6 @@ public interface ArangoPersistentProperty extends PersistentProperty<ArangoPersi

Optional<FulltextIndexed> getFulltextIndexed();

Optional<ArangoSearchLinked> getArangoSearchLinked();

}
Loading