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

Feature update the indexer to work with eXist-6.x.x #12

Merged
merged 13 commits into from
Nov 9, 2023
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
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
jdk: [8]
jdk: [1.8.282,1.11.0,1.17.0-0]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup Scala
uses: olafurpg/setup-scala@v12
uses: olafurpg/setup-scala@v14
with:
java-version: "adopt@1.${{ matrix.jdk }}"
java-version: "zulu@${{ matrix.jdk }}"
- name: Coursier cache
uses: coursier/cache-action@v6
- name: Build
Expand All @@ -31,4 +31,4 @@ jobs:
find $HOME/Library/Caches/Coursier/v1 -name "ivydata-*.properties" -delete || true
find $HOME/.ivy2/cache -name "ivydata-*.properties" -delete || true
find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete || true
find $HOME/.sbt -name "*.lock" -delete || true
find $HOME/.sbt -name "*.lock" -delete || true
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ eXist Indexer for Algolia is a configurable index plug-in for the [eXist-db](htt

## Installation

The Algolia indexer is dependent on https://github.com/BCDH/cql-module follow the install instructions in the `README`.

It's probably a good idea to start with a clean database, which means a completely clean `$EXIST_HOME/webapp/WEB-INF/data` folder.

* The Index plugin requires at least eXist version 3.0.
Expand All @@ -19,7 +21,7 @@ It's probably a good idea to start with a clean database, which means a complete

- Make sure eXist is not running

- Place the jar file named like `exist-algolia-index-assembly-2.13_1.0.0.jar` into eXist's `lib/user`.
- Place the jar file named like `exist-algolia-index-assembly-2.13_1.0.0.jar` into eXist's `lib/user`, `lib` for eXist-db-6.x.x.

- Modify eXist's `conf.xml` file by adding the following line to the `indexer/modules` section:

Expand All @@ -30,6 +32,17 @@ It's probably a good idea to start with a clean database, which means a complete
admin-api-key="YOUR-ALGOLIA-ADMIN-API-KEY"/>
```

### just for exist-6.x.x
- add the dependency in `etc/startup.xml`
```xml
<dependency>
<groupId>Your group id</groupId>
<artifactId>AlgoliaIndex</artifactId>
<version>1.1.0</version>
<relativePath>exist-algolia-index-assembly-1.1.0-SNAPSHOT.jar</relativePath> <!-- this should reflect the exact filename you placed in the lib folder in lib folder -->
</dependency>
```

- Startup eXist.

- For the Collection(s) that you want to index with Algolia, you need to add an Algolia index configuration to eXist's `collection.xconf` file. See [instructions](#collectionconf).
Expand Down
42 changes: 33 additions & 9 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import ReleaseTransformations._

val jaxbApiV = "3.0.1"

val jaxbImplV = "3.0.2"

ThisBuild / versionScheme := Some("semver-spec")

lazy val root = Project("exist-algolia-index", file("."))
Expand All @@ -23,31 +27,43 @@ lazy val root = Project("exist-algolia-index", file("."))
name = "Adam Retter",
email = "[email protected]",
url = url("https://www.evolvedbinary.com")
),
Developer(
id = "mamroure",
name = "Younes Bahloul",
email = "[email protected]",
url = url("https://www.evolvedbinary.com")
)
),
headerLicense := Some(HeaderLicense.GPLv3("2016", "Belgrade Center for Digital Humanities")),
xjcLibs := Seq(
"org.glassfish.jaxb" % "jaxb-xjc" % jaxbImplV,
"org.glassfish.jaxb" % "jaxb-runtime" % jaxbImplV
),
libraryDependencies ++= {

val catsCoreV = "2.10.0"
val existV = "4.4.0"
val existV = "6.3.0-SNAPSHOT"
val algoliaV = "2.19.0"
val akkaV = "2.6.20"
val jacksonV = "2.9.7"
val jacksonV = "2.13.4"

Seq(
"org.scala-lang.modules" %% "scala-java8-compat" % "1.0.2",
"org.typelevel" %% "cats-core" % catsCoreV,

"org.parboiled" %% "parboiled" % "2.5.0",

"jakarta.xml.bind" % "jakarta.xml.bind-api" % jaxbApiV % Provided,
"org.glassfish.jaxb" % "jaxb-runtime" % jaxbImplV % Provided,

"org.clapper" %% "grizzled-slf4j" % "1.3.4"
exclude("org.slf4j", "slf4j-api"),

"org.exist-db" % "exist-core" % existV % Provided
exclude("org.exist-db.thirdparty.javax.xml.xquery", "xqjapi"),
"net.sf.saxon" % "Saxon-HE" % "9.6.0-7" % Provided,
"org.exist-db" % "exist-core" % existV % Provided,
"net.sf.saxon" % "Saxon-HE" % "9.9.1-8" % Provided,
"com.fasterxml.jackson.core" % "jackson-core" % jacksonV % Provided,
"commons-codec" % "commons-codec" % "1.11" % Provided,
"commons-codec" % "commons-codec" % "1.15" % Provided,

"com.fasterxml.jackson.core" % "jackson-databind" % jacksonV
exclude("com.fasterxml.jackson.core", "jackson-core"),
Expand All @@ -66,7 +82,7 @@ lazy val root = Project("exist-algolia-index", file("."))
"org.easymock" % "easymock" % "3.6" % Test,

"org.exist-db" % "exist-start" % existV % Test,
"org.apache.httpcomponents" % "httpclient" % "4.5.6" % Test
"org.apache.httpcomponents" % "httpclient" % "4.5.14" % Test
)
},
publishMavenStyle := true,
Expand All @@ -84,7 +100,8 @@ lazy val root = Project("exist-algolia-index", file("."))
releasePublishArtifactsAction := PgpKeys.publishSigned.value,

resolvers += Resolver.mavenLocal,
resolvers += "eXist Maven Repo" at "https://raw.github.com/eXist-db/mvn-repo/master/"
resolvers += "Evolved Binary eXist-db Release Maven Repo" at "https://repo.evolvedbinary.com/repository/exist-db/",
resolvers += "Evolved Binary eXist-db Snapshot Maven Repo" at "https://repo.evolvedbinary.com/repository/exist-db-snapshots/"
)

// Fancy up the Assembly JAR
Expand Down Expand Up @@ -122,8 +139,15 @@ Compile / assembly / artifact := {
art.withClassifier(Some("assembly"))
}

addArtifact(Compile / assembly / artifact, assembly)
assembly / assemblyMergeStrategy := {
case PathList("META-INF", "versions", "9", xs @ _*) => MergeStrategy.discard
case x if x.endsWith("module-info.class") => MergeStrategy.discard
case x =>
val oldStrategy = (assembly / assemblyMergeStrategy).value
oldStrategy(x)
}

addArtifact(Compile / assembly / artifact, assembly)

pomExtra := (
<developers>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.humanistika.exist.index.algolia

import javax.xml.bind.JAXBContext
import jakarta.xml.bind.JAXBContext

import org.exist.collections.Collection
import org.exist.dom.persistent._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,10 +488,11 @@ class AlgoliaStreamListener(indexWorker: AlgoliaIndexWorker, broker: DBBroker, i
private def isDocumentRootObject(rootObject: RootObject): Boolean = Option(rootObject.getPath).forall(path => path.isEmpty || path.equals("/"))

private def isElementRootObject(currentNode: ElementImpl, path: NodePath)(rootObject: RootObject): Boolean = {
// nodePath(ns, rootObject.getPath) == path

val rootObjectPath = NodePathWithPredicates.parse(ns.asScala.toMap, rootObject.getPath)
if(rootObjectPath.asNodePath == path) {
val rootNodePath: NodePath = rootObjectPath.asNodePath
val pathsEqual: Boolean = rootNodePath.equals(path)

if (pathsEqual) {
nodePathAndPredicatesMatch(currentNode)(rootObjectPath)
} else {
false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.humanistika.exist.index.algolia

import javax.xml.bind.DatatypeConverter
import jakarta.xml.bind.DatatypeConverter

import com.fasterxml.jackson.core.JsonGenerator
import org.humanistika.exist.index.algolia.LiteralTypeConfig.LiteralTypeConfig
Expand Down
Loading