Skip to content

GEODE-vector-pr3: Add gfsh Vector Index Commands, Cluster Configuration XML Persistence, and Vector Metrics (depends on #8154) - #8155

Draft
gouthamaenugu wants to merge 7 commits into
apache:developfrom
gouthamaenugu:feature/GEODE-vector-pr3-gfsh-cli
Draft

gouthamaenugu wants to merge 7 commits into
apache:developfrom
gouthamaenugu:feature/GEODE-vector-pr3-gfsh-cli

Conversation

@gouthamaenugu

@gouthamaenugu gouthamaenugu commented Nov 24, 2026 •

Copy link
Copy Markdown

PR 3: gfsh Vector Index Commands, Cluster Configuration XML Persistence, and Vector Metrics

Dependency Note: Stacked on PR 1 (#8154, gouthamaenugu:feature/GEODE-vector-pr1-knn-field). Because upstream apache/geode does not host feature branches, this Draft PR targets apache:develop and therefore includes PR 1's commits until #8154 lands. Review the PR 3 delta (be90eff48b..43391fee5b, 28 files changed, +2150 / -68); merge after #8154.


For all changes, please confirm:


Summary / Motivation

Building on PR 1 (#8154)'s VectorIndexMetadata, LuceneIndexFactory.addVectorField(...) API, and bounded vector segment compaction, operators need first-class gfsh commands, Cluster Configuration Service XML persistence, and JMX/MXBean observability to create, inspect, query, and monitor vector indexes across an Apache Geode cluster.

This PR adds:

  1. gfsh CLI Support: Vector index creation (create lucene index --vector-field=...) and k-NN / filtered k-NN querying (search lucene --query-vector=... --vector-field=... --k=... --filter-query=...), plus vector metadata reporting in describe lucene index / list lucene indexes.
  2. Cluster Configuration & cache.xml Round-Trip: Extends lucene-1.0.xsd, JAXB Index / Index.VectorField, LuceneXmlParser, and LuceneIndexXmlGenerator so vector indexes persist across locator restarts and automatically apply to newly joining servers.
  3. Observability & Metrics: Exposes live segmentMemoryBytes (backed by the Lucene fileAndChunkRegion partitioned datastore byte count) and vectorFields metadata through LuceneIndexStats, LuceneIndexStatsMonitor, LuceneIndexMetrics, and LuceneIndexDetails.

Key Changes

gfsh Commands, Functions & Query Execution

  • LuceneCreateIndexCommand & LuceneCreateIndexFunction:
    • Added --vector-field option supporting name:dimension[:similarity[:sq8[:M[:efConstruction]]]] specs (repeatable/comma-separated), allowing pure-vector indexes without requiring --field.
    • Strict CLI validation rejecting malformed specs, duplicate --vector-field names, and overlap between --field and --vector-field with UserErrorException.
    • Persists Index.VectorField definitions into Cluster Configuration (updateConfigForGroup).
  • LuceneSearchIndexCommand, LuceneSearchIndexFunction, LuceneQueryInfo, & VectorKnnQueryProvider:
    • Added --query-vector, --vector-field, --k, and --filter-query options.
    • Strict input validation rejecting --limit <= 0, unmatched brackets, empty/trailing vector commas (split(",", -1)), and orphan --vector-field/--k/--filter-query flags without --query-vector.
    • LuceneSearchIndexFunction respects queryInfo.getLimit() while passing k to VectorKnnQueryProvider; VectorKnnQueryProvider.parseFilterQuery closes fallback StandardAnalyzer cleanly via try-with-resources and fails fast on unqualified --filter-query against pure-vector indexes.
  • LuceneIndexInfo & LuceneIndexDetails:
    • Extended CLI transfer objects to carry vectorFields metadata and live segmentMemoryBytes.

XML Schema & Cluster Configuration Persistence

  • lucene-1.0.xsd, Index (Index.VectorField), LuceneXmlParser, LuceneIndexXmlGenerator, LuceneXmlConstants:
    • Added optional <lucene:vector-field name="..." dimension="..." similarity="..." max-connections="..." beam-width="..." quantize-sq8="..."/> element to lucene-1.0.xsd (backward compatible with existing cache.xml documents).
    • Strict XML parsing validates quantize-sq8 (true/false only) and rejects duplicate <vector-field> definitions with CacheXmlException.

Metrics & JMX Observability

  • LuceneIndexStats, LuceneIndexForPartitionedRegion, LuceneIndexStatsMonitor, StatsKey, LuceneIndexMetrics:
    • Wired a live volatile LongSupplier in LuceneIndexStats connected directly to getFileAndChunkRegion().getPrStats().getDataStoreBytesInUse(), ensuring getSegmentMemoryBytes() reflects live memory usage even when statistic-sampling-enabled=false.
    • Exposed getSegmentMemoryBytes() and getVectorFields() on LuceneIndexMetrics MXBean CompositeType while retaining all legacy constructors for backward compatibility.

New Unit & Distributed Tests (20 PR 3 Unit + 2 DUnit)

  • LuceneVectorCommandsJUnitTest (7 tests): CLI parsing, pure-vector index creation, duplicate/overlap rejection, malformed vector/bracket/limit validation, and search flag validation.
  • LuceneVectorFunctionsJUnitTest (6 tests): LuceneCreateIndexFunction, LuceneSearchIndexFunction limit vs k, VectorKnnQueryProvider filtered k-NN, and unqualified filter fail-fast checks.
  • LuceneVectorMetricsJUnitTest (4 tests): live segmentMemoryBytes without statistics sampling, LuceneIndexStatsMonitor, LuceneIndexMetrics backward-compatible constructors and MXBean getters.
  • LuceneVectorXmlRoundTripJUnitTest (3 tests): cache.xml + LuceneIndexXmlGenerator / LuceneXmlParser round-trip, strict quantize-sq8 validation, and duplicate <vector-field> rejection.
  • LuceneVectorClusterConfigurationDUnitTest (2 DUnit tests): real locator + servers creating a vector index via gfsh, persisting XML in Cluster Configuration, joining a new server dynamically, and executing search lucene --query-vector=... end-to-end.

Backward Compatibility & Serialization Notes

  • Backward-Compatible Schema & MXBean: <lucene:vector-field> is optional (minOccurs="0" maxOccurs="unbounded") in lucene-1.0.xsd. Legacy LuceneIndexMetrics, LuceneIndexInfo, LuceneIndexDetails, and LuceneQueryInfo constructors are preserved as delegating overloads.
  • Sanctioned Serializables & Assembly Manifest: Updated sanctioned-geode-lucene-serializables.txt for VectorKnnQueryProvider, Index, Index$VectorField, LuceneIndexInfo, LuceneIndexDetails, and LuceneQueryInfo, verified with AnalyzeLuceneSerializablesIntegrationTest.testSerializables and real P2P serialization in LuceneVectorClusterConfigurationDUnitTest; added javadoc/org/apache/geode/cache/lucene/management/configuration/Index.VectorField.html to geode-assembly/src/integrationTest/resources/assembly_content.txt.

Exact Gradle Verification Commands & Pass Counts

(Baseline counts captured on 5a23353669; follow-up commit 43391fee5b rebases onto PR 1 be90eff48b and adds the assembly_content.txt entry for Index.VectorField.)

./gradlew --no-daemon --max-workers=2 \
  :geode-lucene:spotlessCheck \
  :geode-gfsh:spotlessCheck \
  :geode-lucene:checkPom \
  :geode-lucene:javadoc \
  :geode-lucene:test --rerun \
  :geode-gfsh:test

./gradlew --no-daemon --max-workers=2 \
  :geode-lucene:distributedTest --tests "*LuceneVectorClusterConfigurationDUnitTest*"

./gradlew --no-daemon --max-workers=2 \
  :geode-lucene:integrationTest \
  --tests "org.apache.geode.codeAnalysis.AnalyzeLuceneSerializablesIntegrationTest.testSerializables"
Verification Suite Total Passed Failed Skipped Status
:geode-lucene:test --rerun 349 345 0 4 (pre-existing) PASS
Vector Unit Suites (20 PR 3 + 46 PR 1) 66 66 0 0 PASS
:geode-gfsh:test 966 964 0 2 (pre-existing) PASS
LuceneVectorClusterConfigurationDUnitTest 2 2 0 0 PASS (19.51s)
AnalyzeLuceneSerializablesIntegrationTest.testSerializables 1 1 0 0 PASS
spotlessCheck (geode-lucene, geode-gfsh), checkPom, javadoc — — 0 — PASS

Per-Suite Vector & DUnit Test Breakdown

PR 3 (:geode-lucene:test): total=349, passed=345, failed=0, errors=0, skipped=4
  - org.apache.geode.cache.lucene.VectorIndexMetadataJUnitTest: 10/10 passed (0 failed, 0 errors, 0 skipped, 0.265s)
  - org.apache.geode.cache.lucene.internal.VectorIndexProfileAndFactoryJUnitTest: 13/13 passed (0 failed, 0 errors, 0 skipped, 0.009s)
  - org.apache.geode.cache.lucene.internal.VectorSegmentCompactionJUnitTest: 5/5 passed (0 failed, 0 errors, 0 skipped, 2.614s)
  - org.apache.geode.cache.lucene.internal.cli.commands.LuceneVectorCommandsJUnitTest: 7/7 passed (0 failed, 0 errors, 0 skipped, 0.243s)
  - org.apache.geode.cache.lucene.internal.cli.functions.LuceneVectorFunctionsJUnitTest: 6/6 passed (0 failed, 0 errors, 0 skipped, 0.033s)
  - org.apache.geode.cache.lucene.internal.management.LuceneVectorMetricsJUnitTest: 4/4 passed (0 failed, 0 errors, 0 skipped, 0.003s)
  - org.apache.geode.cache.lucene.internal.repository.serializer.VectorCodecRecallJUnitTest: 4/4 passed (0 failed, 0 errors, 0 skipped, 0.287s)
  - org.apache.geode.cache.lucene.internal.repository.serializer.VectorFieldMapperJUnitTest: 14/14 passed (0 failed, 0 errors, 0 skipped, 0.014s)
  - org.apache.geode.cache.lucene.internal.xml.LuceneVectorXmlRoundTripJUnitTest: 3/3 passed (0 failed, 0 errors, 0 skipped, 0.112s)
PR 3 (:geode-gfsh:test): total=966, passed=964, failed=0, errors=0, skipped=2
PR 3 (:geode-lucene:distributedTest): total=2, passed=2, failed=0, errors=0, skipped=0
  - org.apache.geode.cache.lucene.internal.configuration.LuceneVectorClusterConfigurationDUnitTest: 2/2 passed (0 failed, 0 errors, 0 skipped, 19.505s)

@gouthamaenugu
gouthamaenugu force-pushed the feature/GEODE-vector-pr3-gfsh-cli branch from 5a23353 to 43391fe Compare November 25, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant