Skip to content
Closed
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
150 changes: 150 additions & 0 deletions lucene/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.arcadedb</groupId>
<artifactId>arcadedb-parent</artifactId>
<version>25.6.1-SNAPSHOT</version> <!-- Use the current ArcadeDB version -->
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>arcadedb-lucene</artifactId>
<packaging>jar</packaging>
<name>ArcadeDB Lucene</name>
<description>Lucene full-text search engine integration for ArcadeDB.</description>

<properties>
<!-- Define Lucene version, ensure it aligns with arcadedb-engine if not inherited -->
<!-- arcadedb-engine already defines lucene.version as 10.2.1 -->
<!-- spatial4j.version and jts-core.version are also defined in engine's POM -->
<lucene.version>10.2.1</lucene.version>
<spatial4j.version>0.8</spatial4j.version>
<jts-core.version>1.20.0</jts-core.version>
</properties>

<dependencies>
<!-- ArcadeDB Core Dependency -->
<dependency>
<groupId>com.arcadedb</groupId>
<artifactId>arcadedb-engine</artifactId>
<version>${project.version}</version>
</dependency>

<!-- Apache Lucene Dependencies -->
<!-- These versions will be managed by the lucene.version property in arcadedb-engine's pom -->
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analysis-common</artifactId>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser</artifactId>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queries</artifactId>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-misc</artifactId>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-facet</artifactId>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-memory</artifactId>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-highlighter</artifactId>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-codecs</artifactId>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-backward-codecs</artifactId>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-spatial-extras</artifactId>
<version>${lucene.version}</version>
</dependency>

<!-- Spatial Dependencies -->
<!-- These versions will be managed by properties in arcadedb-engine's pom -->
<dependency>
<groupId>org.locationtech.spatial4j</groupId>
<artifactId>spatial4j</artifactId>
<version>${spatial4j.version}</version>
</dependency>
<dependency>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-core</artifactId>
<version>${jts-core.version}</version>
</dependency>

<!-- SLF4J for logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version> <!-- Specify a common version -->
</dependency>
Comment on lines +108 to +112

Check notice

Code scanning / Meterian

[stability] org.slf4j:slf4j-api@1.7.36 is outdated Low

org.slf4j:slf4j-api@1.7.36 is outdated

<!-- Test Dependencies (Optional for now, can be added in Test Migration step) -->
<!--
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
-->
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
</archive>
</configuration>
</plugin>
<!--
Consider adding maven-shade-plugin here if an uber-jar is desired,
similar to how arcadedb-server and other modules might be packaged.
For now, a regular JAR is fine. Configuration can be adapted from parent POM.
-->
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package com.arcadedb.lucene;

import com.arcadedb.database.DatabaseInternal;
import com.arcadedb.index.IndexFactoryHandler;
import com.arcadedb.index.IndexInternal;
import com.arcadedb.schema.IndexBuilder;
import com.arcadedb.schema.Type;
import com.arcadedb.lucene.index.ArcadeLuceneFullTextIndex;
import java.util.Map;

public class ArcadeLuceneIndexFactoryHandler implements IndexFactoryHandler {

public static final String LUCENE_FULL_TEXT_ALGORITHM = "LUCENE"; // Or just "LUCENE"
public static final String LUCENE_CROSS_CLASS_ALGORITHM = "LUCENE_CROSS_CLASS";


@Override
public IndexInternal create(IndexBuilder builder) {
DatabaseInternal database = builder.getDatabase();
String indexName = builder.getIndexName();
// boolean unique = builder.isUnique(); // Unique is part of IndexDefinition
// Type[] keyTypes = builder.getKeyTypes(); // Key types are part of IndexDefinition

// The IndexDefinition is the primary source of truth for index properties.
IndexDefinition definition = builder.getIndexDefinition();
if (definition == null) {
// This case should ideally be prevented by the schema/builder logic before reaching here.
// If it can happen, we might need to construct a minimal definition.
// For now, assuming builder provides a valid definition or enough info to create one.
// If builder.build() is called before this, definition should be set.
// If this factory *is* part of builder.build(), then builder has all components.
throw new IllegalArgumentException("IndexDefinition is required to create a Lucene index.");
}

// Algorithm is now part of IndexDefinition
// String algorithm = definition.getAlgorithm() != null ? definition.getAlgorithm() : LUCENE_FULL_TEXT_ALGORITHM;
// The factory is usually registered for a specific algorithm, so this check might be redundant
// if this factory is only invoked for "LUCENE" or "LUCENE_CROSS_CLASS".

// The constructor for ArcadeLuceneFullTextIndex is:
// (DatabaseInternal db, String name, String typeName, IndexDefinition definition,
// String filePath, PaginatedFile metadataFile, PaginatedFile[] dataFiles,
// PaginatedFile[] treeFiles, int fileId, int pageSize,
// TransactionContext.AtomicOperation atomicOperation)
// The IndexBuilder provides most of these.
// typeName here is the schema type name the index is on, not the index type/algorithm.

// filePath should be determined by the system, often databasePath + indexFileName
String filePath = builder.getFilePath();
if (filePath == null) {
filePath = database.getDatabasePath() + java.io.File.separator + builder.getFileName();
}


// For PaginatedFile parameters, they are usually managed by the Storage engine.
// For a Lucene index, it might not directly use these ArcadeDB PaginatedFile structures
// for its main data, but it might have a metadata file.
// The IndexBuilder should provide these if they are standard.
// If Lucene manages its own files in 'filePath', some of these might be null or placeholders.

// Let's assume the builder provides what's needed for the generic parts of an index.
// The specific engine (Lucene) will manage its own data files within its directory (filePath).

// The old constructor of ArcadeLuceneFullTextIndex took:
// (DatabaseInternal database, String name, boolean unique, String analyzerClassName, String filePath, Type[] keyTypes)
// This has been changed to the standard one.
// We need to ensure that IndexDefinition within builder has all necessary info (like analyzer).
// Analyzer is typically stored in definition.getOptions().get("analyzer")

return new ArcadeLuceneFullTextIndex(
database,
indexName,
definition.getTypeName(), // Class/Type name this index is on
definition,
filePath,
builder.getMetadataFile(), // from IndexBuilder
builder.getDataFiles(), // from IndexBuilder
builder.getTreeFiles(), // from IndexBuilder (likely null/unused for Lucene)
builder.getFileId(), // from IndexBuilder
builder.getPageSize(), // from IndexBuilder (might be less relevant for Lucene)
null // AtomicOperation: build is usually outside a TX or handles its own.
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2010-2016 OrientDB LTD (http://orientdb.com)
*
* 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.
*/

package com.arcadedb.lucene;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

// This class might serve as the main plugin class listed in plugin.json for initialization purposes,
// or handle lifecycle events if ArcadeDB's plugin API expects a specific class for that.
// For now, it's minimal.
public class ArcadeLuceneLifecycleManager {
private static final Logger logger = LoggerFactory.getLogger(ArcadeLuceneLifecycleManager.class);

// This constant might be better placed in ArcadeLuceneIndexFactoryHandler or a shared constants class.
public static final String LUCENE_ALGORITHM = "LUCENE";

public ArcadeLuceneLifecycleManager() {
this(false);
}

public ArcadeLuceneLifecycleManager(boolean manual) {
if (!manual) {
logger.info("ArcadeLuceneLifecycleManager initialized (manual: {}).", manual);
// Further initialization or listener registration logic specific to ArcadeDB's plugin system
// would go here if this class is the entry point.
}
}

// Any necessary lifecycle methods (e.g., from a specific ArcadeDB plugin interface) would be here.
// For now, assuming it does not need to implement DatabaseListener directly.
// Drop logic for indexes of this type should be handled by the Index.drop() method.
}
Loading
Loading