Skip to main content

JME OpenSearch Example

Source on GitHub

This project demonstrates event-driven indexing and authorization-aware searches using the jEAP OpenSearch components. It is self-contained for local development and provides portable application artifacts for deployment-specific wrappers.

The example covers two indexing flows:

  1. The included resource service creates transit data and publishes a Kafka message. The index writer consumes the message, retrieves the corresponding SearchItem over HTTP and writes it to OpenSearch.
  2. An optional integration consumes archived-artifact events from the JME Process Archive example and indexes decrees and decree documents. The application code is portable; the external topic, endpoint and OAuth configuration is supplied by the deployment environment.

Modules​

ModulePurposeLocal port
jme-opensearch-auth-scsLocal OAuth2 mock server8180
jme-opensearch-resource-serviceCreates transit data, publishes messages and provides SearchItems8581
jme-opensearch-index-writer-serviceConsumes messages, retrieves SearchItems and writes them to OpenSearch; with maintenance enabled also stores upsert and delete jobs submitted as YAML8580
jme-opensearch-inspection-serviceProvides type-safe, authorization-aware OpenSearch queries8582
jme-opensearch-testRuns the portable transit flows, the maintenance job API and the maintenance target policy checks end-to-end against local infrastructure, confirming the default non-rollover index lifecycle-

Architecture​

The index writer's opensearch/messages.json maps each message and topic to an index type, reference provider, optional condition and remote SearchItems endpoint. Index types and mappings are generated by the JME index type registry.

The transit-document flow demonstrates each generated field shape:

Mapping fieldOpenSearch shapeGenerated Java component
goods_descriptionScalarString
keywordsScalar collectionList<String>
customs_checksNested collectionList<CustomsChecks>
customs_checks.officeNested scalarString
customs_checks.tagsNested scalar collectionList<String>
customs_checks.detailsSingle nested objectDetails
customs_checks.details.codesScalar collection in a single nested objectList<String>

The source mapping is defined in the index type registry at index-types/jme/jmetransitdocument/JmeTransitDocument_mapping_v1_3.json. The generated Java object is the ch/admin/bit/jme/opensearch/index/jme/transitdocument/JmeTransitDocumentDataV1.java entry in the jme-transit-document-v1-1.3-sources.jar artifact. Download the sources with ./mvnw dependency:get -Dartifact=ch.admin.bit.jeap.jme.indextype.jme:jme-transit-document-v1:1.3:jar:sources. The generated source is then available in ~/.m2/repository/ch/admin/bit/jeap/jme/indextype/jme/jme-transit-document-v1/1.3/jme-transit-document-v1-1.3-sources.jar.

The end-to-end test verifies that these values survive resource serialization, indexing, typed search-result deserialization and field-specific OpenSearch queries.

The transit-decision V3 flow demonstrates native OpenSearch analysis settings supplied by an index type. Its custom analyzer maps & to and, splits text on whitespace and hyphens, lowercases and folds accents, and removes and as a stopword. Consequently, the remark Café & Müller-AG is indexed as the tokens cafe, muller, ag. A custom normalizer makes the keyword Peter Müller searchable as peter muller. OpenSearch still returns the original accented values from _source.

These settings are defined in the index type registry's JmeTransitDecision_mapping_v3_0.json. Analysis changes require a new index-type major version because existing documents must be reindexed with the new analysis chain.

Prerequisites​

Use the included Maven wrapper for all Maven commands.

Build And Test​

./mvnw clean verify

The build runs unit tests and license checks as well as two levels of integration testing:

  • The inspection-service integration test starts that application with a real OpenSearch Testcontainer, indexes a document directly and queries it through the authorization-aware REST API.
  • The jme-opensearch-test module starts the Compose infrastructure and all four applications. It creates transit documents and decisions through the resource API, waits for Kafka processing and verifies the resulting documents through the OAuth-protected inspection API. It submits and retrieves upsert and delete jobs through the YAML API, checks their OpenAPI entries, starts a second index writer instance to show that stored jobs are reused and one with maintenance disabled (see Maintenance Jobs). It also verifies that the job API refuses a delete job whose target has a rolling ISM policy applied (see Maintenance Target Policy Check); this waits for ISM to apply the demo policy on its next job run, which adds up to a few minutes.

Run only the complete local end-to-end test with:

./mvnw verify -pl jme-opensearch-test

Docker must be available and ports 8180, 8580-8582, 9200, 12000 and 13000 must be free. The test starts and stops its applications and Compose project automatically.

Local Development​

Infrastructure​

Start Kafka in KRaft mode, Schema Registry, OpenSearch and OpenSearch Dashboards:

docker compose --file docker/docker-compose.yml up --detach --wait

Applications​

Run the applications in separate terminals, in the order shown:

./mvnw -pl jme-opensearch-auth-scs spring-boot:run -Dspring-boot.run.profiles=local
./mvnw -pl jme-opensearch-resource-service spring-boot:run -Dspring-boot.run.profiles=local
./mvnw -pl jme-opensearch-index-writer-service spring-boot:run -Dspring-boot.run.profiles=local
./mvnw -pl jme-opensearch-inspection-service spring-boot:run -Dspring-boot.run.profiles=local

Local endpoints:

ComponentURL
Index writer Swagger UI (maintenance job API)http://localhost:8580/jme-opensearch-index-writer-service/swagger-ui/index.html
Resource service Swagger UIhttp://localhost:8581/jme-opensearch-resource-service/swagger-ui/index.html
Inspection service Swagger UIhttp://localhost:8582/jme-opensearch-inspection-service/swagger-ui/index.html
OpenSearch APIhttp://localhost:9200
OpenSearch Dashboardshttp://localhost:5601

Try The Example​

Create a V3 transit decision with analyzed example values:

DECISION=$(curl --fail --silent --request POST \
http://localhost:8581/jme-opensearch-resource-service/api/v3/transitdescisions)
jq . <<< "$DECISION"

Obtain an access token from the local OAuth mock:

TOKEN=$(curl --fail --silent --request POST \
http://localhost:8180/jme-opensearch-auth-scs/oauth2/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id=inspection-internal-sys' \
--data-urlencode 'client_secret=secret' | jq --raw-output '.access_token')

Create a transit document and extract one value of each field shape:

DOCUMENT=$(curl --fail --silent --request POST \
http://localhost:8581/jme-opensearch-resource-service/api/transitdocuments)
GOODS_PREFIX=$(jq --raw-output '.searchItem.data.goods_description | split(" ")[0]' <<< "$DOCUMENT")
KEYWORD=$(jq --raw-output '.searchItem.data.keywords[0]' <<< "$DOCUMENT")
CUSTOMS_OFFICE=$(jq --raw-output '.searchItem.data.customs_checks[0].office' <<< "$DOCUMENT")
CUSTOMS_TAG=$(jq --raw-output '.searchItem.data.customs_checks[0].tags[0]' <<< "$DOCUMENT")
CUSTOMS_CODE=$(jq --raw-output '.searchItem.data.customs_checks[0].details.codes[0]' <<< "$DOCUMENT")
jq . <<< "$DOCUMENT"

After the Kafka message has been processed, search by the scalar, collection and nested values:

curl --fail --silent --get \
http://localhost:8582/jme-opensearch-inspection-service/api/transitdocuments \
--data-urlencode "goodsDescription=$GOODS_PREFIX" \
--header "Authorization: Bearer $TOKEN" | jq .

curl --fail --silent --get \
http://localhost:8582/jme-opensearch-inspection-service/api/transitdocuments/by-keyword \
--data-urlencode "keyword=$KEYWORD" \
--header "Authorization: Bearer $TOKEN" | jq .

curl --fail --silent --get \
http://localhost:8582/jme-opensearch-inspection-service/api/transitdocuments/by-customs-office \
--data-urlencode "office=$CUSTOMS_OFFICE" \
--header "Authorization: Bearer $TOKEN" | jq .

curl --fail --silent --get \
http://localhost:8582/jme-opensearch-inspection-service/api/transitdocuments/by-customs-tag \
--data-urlencode "tag=$CUSTOMS_TAG" \
--header "Authorization: Bearer $TOKEN" | jq .

curl --fail --silent --get \
http://localhost:8582/jme-opensearch-inspection-service/api/transitdocuments/by-customs-code \
--data-urlencode "code=$CUSTOMS_CODE" \
--header "Authorization: Bearer $TOKEN" | jq .

After the Kafka message has been processed, search for the indexed decision:

curl --fail --silent --get \
http://localhost:8582/jme-opensearch-inspection-service/api/transitdecisions \
--data-urlencode 'decidedBy=peter muller' \
--header "Authorization: Bearer $TOKEN" | jq .

curl --fail --silent --get \
http://localhost:8582/jme-opensearch-inspection-service/api/transitdecisions/by-remarks \
--data-urlencode 'remarks=cafe muller' \
--header "Authorization: Bearer $TOKEN" | jq .

Request the current data of the decision in a fixed schema major, as a maintenance job does. This uses the index writer's OAuth client, which holds the searchitem:read role:

READ_TOKEN=$(curl --fail --silent --request POST \
http://localhost:8180/jme-opensearch-auth-scs/oauth2/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id=index-writer-read-client' \
--data-urlencode 'client_secret=secret' | jq --raw-output '.access_token')
DECISION_ID=$(jq --raw-output '.searchItem.origin.id' <<< "$DECISION")

for MAJOR in 1 2 4; do
curl --silent --include --get \
http://localhost:8581/jme-opensearch-resource-service/index-api/searchitems \
--data-urlencode 'index_type=JmeTransitDecision' \
--data-urlencode "origin_id=$DECISION_ID" \
--data-urlencode "index_major_version=$MAJOR" \
--header "Authorization: Bearer $READ_TOKEN"
echo
done

The same current decision is returned for majors 1 and 2. The payload shape follows the major (transit_decision_id in major 1, transit_decision_identifier in major 2), and the index-major-version / index-minor-version headers state what the provider produced. origin.version (1.0.0) is the business revision of the decision and is the same in both answers. The schema major is neither that version nor a physical index name: the writer derives the target index (jme_transit_decision_v1_write) from the index type. Major 4 does not exist, so the provider answers 422 UNSUPPORTED_INDEX_MAJOR_VERSION instead of returning another major.

Inspect the created indices:

curl --fail --silent 'http://localhost:9200/_cat/indices?v'

Index Lifecycle​

This example's business indices (jme_transit_document_v*, jme_transit_decision_v*, jme_decree_document_v*) have no ISM (Index State Management) policy attached by default — this is the normal setup, not something to configure away. Each is created once as <name>-000001 and written, updated and deleted from indefinitely through its write alias; the -000001 suffix only supports a future rollover and does not itself enable one. Normal indexing, updating, deleting and searching all work this way, including after restarting the stack.

Verify the applied policy of a real business index with ISM Explain:

curl --fail --silent 'http://localhost:9200/_plugins/_ism/explain/jme_transit_decision_v1-000001?show_policy=true' | jq .

A missing policy_id confirms no policy is attached. Compare this with the jme_policy_check_rolling-000001 demo index below, which has a rollover policy deliberately attached to demonstrate the opposite case.

Without rollover, there is no automatic age-based deletion and the single index keeps growing — plan number-of-shards in jme-opensearch-index-writer-service/src/main/resources/application-local.yml for the expected volume, and decide deliberately how (or whether) your domain retires old documents, rather than relying on index age. Rollover remains available as a separate, deliberate opt-in: attach an ISM policy via ism_template matching the index pattern, exactly as demonstrated for the throwaway demo index in the Maintenance Target Policy Check section below. The maintenance job/task indices (jeap_indexwriter_jobs, jeap_indexwriter_tasks, see Maintenance Jobs) must stay outside any such policy if maintenance is enabled: their retention is handled by the service's own housekeeping, not by OpenSearch deleting the index.

Maintenance Jobs​

An operator submits an upsert or delete job as YAML and reads the YAML report. Accepted jobs are run in the background: an upsert task fetches the current data from the SearchItem Provider in the job's schema major and replaces or creates the document in the stored target; a delete task removes the id from every target selected when the job was accepted (one explicit major, or every major configured for the index type when indexMajorVersion is omitted). The local profile enables the feature with jeap.opensearch.indexwriter.maintenance.enabled=true; the default is false, and then the service has no job endpoints, no OpenAPI entries, no job indices and no housekeeping, while normal indexing works as before. See the library documentation.

Running jobs needs two Kafka topics specific to this service instance, one command per task: the service produces to and consumes from both itself, so the topics must differ and the service principal needs ACLs for both (see upsert-command-topic / delete-command-topic in jme-opensearch-index-writer-service/src/main/resources/application-local.yml, and the matching @JeapMessageProducerContract / @JeapMessageConsumerContract declarations in JmeOpenSearchIndexWriterConfiguration). Startup fails if either topic is unset, if they are equal, or if a contract for UpsertSearchItemCommand / DeleteSearchItemCommand on its topic is missing.

The OAuth mock provides two clients for the job API:

ClientRoles
job-operator-sysupsertjob#create, deletejob#create, jobreport#read
job-reader-sysjobreport#read only (creating a job answers 403)
JOB_TOKEN=$(curl --fail --silent --request POST \
http://localhost:8180/jme-opensearch-auth-scs/oauth2/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id=job-operator-sys' \
--data-urlencode 'client_secret=secret' | jq --raw-output '.access_token')
WRITER=http://localhost:8580/jme-opensearch-index-writer-service

Submit an upsert job with an explicit schema major. The version "3" of the first reference is business metadata that is only stored and reported. It never selects a schema, a provider request or a rollback:

JOB_ID=$(uuidgen)
curl --fail --silent --request PUT "$WRITER/api/upsert-jobs/$JOB_ID" \
--header "Authorization: Bearer $JOB_TOKEN" --header 'Content-Type: application/yaml' --data-binary @- <<'YAML'
message:
messageName: JmeTransitDecisionCreatedEvent
topicName: jme-transit-decision-created
operation:
indexType: JmeTransitDecision
indexOperation: UPSERT
indexMajorVersion: 2
originReferences:
- id: 'ref-1'
version: '3'
- id: 'ref-2'
YAML

The report names the one fixed target (selection: explicit, index-major-version: 2, physical-index: jme_transit_decision_v2-000001) and keeps version: "3". Read it again, also after a restart:

curl --fail --silent "$WRITER/api/upsert-jobs/$JOB_ID" \
--header "Authorization: Bearer $JOB_TOKEN" --header 'Accept: application/yaml'

Omit indexMajorVersion to select the highest configured major (3 for JmeTransitDecision; selection: highest). The references ref-1 and ref-2 do not exist at the resource service, so both tasks end as failed with SOURCE_NOT_FOUND; Run Maintenance Jobs With The jEAP CLI repairs a real document. Delete jobs have IDs only. With indexMajorVersion they delete from that major only; without it, from every major configured for the index type (target-selection: all):

curl --fail --silent --request PUT "$WRITER/api/delete-jobs/$(uuidgen)" \
--header "Authorization: Bearer $JOB_TOKEN" --header 'Content-Type: application/yaml' --data-binary @- <<'YAML'
indexType: JmeTransitDecision
indexMajorVersion: 1
originReferences:
- id: 'ref-1'
- id: 'ref-2'
YAML
RequestAnswer
Same job ID, equivalent content200, the retained job (submitter and timestamps do not matter)
Same job ID, changed indexMajorVersion or stored reference version409
Unknown major, duplicate IDs (even with different versions), version or allowRollback on a delete job, too many references400, nothing stored
Content type other than application/yaml / application/x-yaml415
Rollover policy or multi-index layout on the target422 NOT_ALLOWED
No token (GET / PUT) / missing role / unknown job / storage unavailable401 / 403 / 403 / 404 / 503

A PUT without token is answered with 403, not 401: the jEAP security chain checks CSRF before authentication, and only requests that carry a bearer token are exempt from it.

With maintenance enabled the service creates the missing job and task indices (jeap_indexwriter_jobs, jeap_indexwriter_tasks) on startup and reuses compatible existing ones, so jobs survive a restart. Open the Swagger UI of the index writer (see the endpoint table) to see both operations with their YAML examples, all responses and the required role.

Run Maintenance Jobs With The jEAP CLI​

Operators do not build these requests by hand: the jeap osiws commands of the jEAP CLI submit a job from a YAML file and a CSV list of IDs, print its UUID and export the complete report. The CLI reads the access token from stdin and only accepts HTTPS URLs; the local index writer runs on plain HTTP on a loopback address, which needs the explicit opt-in --allow-insecure-http=true.

This walkthrough repairs a document that is missing in a schema major, then removes it from every major. Create a V3 transit decision. The normal event flow indexes it into major 3 only:

DECISION_ID=$(curl --fail --silent --request POST \
http://localhost:8581/jme-opensearch-resource-service/api/v3/transitdescisions | jq --raw-output '.searchItem.origin.id')
printf 'id\n%s\n' "$DECISION_ID" > ids.csv
found() { curl --silent "http://localhost:9200/jme_transit_decision_v$1-000001/_doc/$DECISION_ID" | jq '.found'; }
echo "v1=$(found 1) v2=$(found 2) v3=$(found 3)" # v1=false v2=false v3=true

An accepted job runs in the background, and its report says job-state: open until the next housekeeping run after its last task (every two seconds locally, every minute by default) completes it. await_job exports the report to <job-type>-report.yaml until the job is completed, then prints it:

await_job() {
until jeap osiws report --job-type="$1" --job-id="$2" --url="$WRITER" --allow-insecure-http=true \
--output="$1-report.yaml" <<< "$JOB_TOKEN" && grep --quiet '^job-state: completed' "$1-report.yaml"; do
sleep 2
done
cat "$1-report.yaml"
}

Wait for a job to complete before you check the index or submit the next job for the same IDs: jobs run independently, so a delete job submitted right away can run before the upsert job has written the document.

Submit an upsert job for major 1. The job fetches the decision's current major-1 data from the resource service and creates the missing document:

cat > upsert-job.yaml <<'YAML'
message:
messageName: JmeTransitDecisionCreatedEvent
topicName: jme-transit-decision-created
operation:
indexType: JmeTransitDecision
indexMajorVersion: 1
YAML
UPSERT_JOB_ID=$(jeap osiws upsert --file=upsert-job.yaml --csv=ids.csv --url="$WRITER" \
--allow-insecure-http=true <<< "$JOB_TOKEN")
await_job upsert "$UPSERT_JOB_ID"
echo "v1=$(found 1) v2=$(found 2) v3=$(found 3)" # v1=true v2=false v3=true

The CLI writes the job UUID to stderr before sending the request, and to stdout once the job is accepted. The completed report has job-result: succeeded, target with selection: explicit and physical-index: jme_transit_decision_v1-000001, and the reference with state: succeeded and actual-index-major-version: 1.

Delete the decision from every configured major. The delete CSV has the id column only, so ids.csv is reused:

printf 'indexType: JmeTransitDecision\n' > delete-job.yaml
DELETE_JOB_ID=$(jeap osiws delete --file=delete-job.yaml --csv=ids.csv --url="$WRITER" \
--allow-insecure-http=true <<< "$JOB_TOKEN")
await_job delete "$DELETE_JOB_ID"
echo "v1=$(found 1) v2=$(found 2) v3=$(found 3)" # v1=false v2=false v3=false

The completed report has job-result: succeeded and target-selection: all with the targets of majors 1, 2 and 3. Per target, the reference shows the deletion-outcome: deleted for majors 1 and 3, already-absent (a success) for major 2.

The CLI validates the input before contacting the index writer, and shows the index writer's error otherwise:

InputCLI answer
version column in a delete CSVRejected: delete jobs have IDs only
Same ID twice, also with different versionsRejected
Token of job-reader-sys for upsert or deleteThe index writer denied the request. The access token needs role upsertjob#create. (or deletejob#create)
http:// URL without --allow-insecure-http=trueRejected: HTTPS is required except for an explicit loopback opt-in

The resource service keeps its data in memory only. After it restarts, upsert jobs for IDs created before fail with SOURCE_NOT_FOUND; create a new decision to repeat the walkthrough.

Stop the running index writer, then start it with maintenance disabled to see the default behaviour. The job endpoints answer 404, the OpenAPI document lists no job paths, and the stored jobs stay untouched in OpenSearch:

./mvnw -pl jme-opensearch-index-writer-service spring-boot:run -Dspring-boot.run.profiles=local \
-Dspring-boot.run.arguments=--jeap.opensearch.indexwriter.maintenance.enabled=false
curl --silent --output /dev/null --write-out '%{http_code}\n' "$WRITER/api/upsert-jobs/$JOB_ID" \
--header "Authorization: Bearer $JOB_TOKEN"
curl --silent "http://localhost:9200/jeap_indexwriter_jobs/_count"

Maintenance Target Policy Check​

A maintenance job writes to one fixed physical target index, so the index writer refuses a target that is managed by a rolling ISM policy. When a job is created, JobTargetAcceptanceCheck reads the policy applied to the target once with ISM Explain. It looks for a rollover action in every state of the policy, including states the index has not reached yet. The job API of the previous section calls this check when a job is submitted and answers 422 NOT_ALLOWED for a refused target; OpenSearchExampleIT verifies this refusal end-to-end through the job API against a live index with a rolling policy attached. The full outcome matrix below (no policy, non-rolling policy, undetermined policy, invalid/missing/non-concrete targets) is already covered by IsmAppliedPolicyInspectorIT in jeap-opensearch-index-writer-service; the calls below show what the check reads so you can reproduce each outcome manually against this example's OpenSearch.

The target must be the physical index (for example jme_transit_decision_v1-000001), not the write or read alias. An alias, a missing index and an invalid name are not policy results: the check throws JobTargetNotConcreteException, JobTargetNotFoundException or JobTargetNameInvalidException.

Attach a policy whose rollover action is in a later state to a demo index:

curl --fail --silent --request PUT http://localhost:9200/jme_policy_check_rolling-000001 \
--header 'Content-Type: application/json' --data '{"settings":{"number_of_replicas":0}}'
curl --fail --silent --request PUT http://localhost:9200/_plugins/_ism/policies/jme-policy-check-rollover \
--header 'Content-Type: application/json' --data '{"policy":{"description":"demo","default_state":"hot","states":[
{"name":"hot","actions":[],"transitions":[{"state_name":"warm","conditions":{"min_index_age":"3650d"}}]},
{"name":"warm","actions":[{"rollover":{"min_doc_count":100000000}}],"transitions":[]}]}}'
curl --fail --silent --request POST http://localhost:9200/_plugins/_ism/add/jme_policy_check_rolling-000001 \
--header 'Content-Type: application/json' --data '{"policy_id":"jme-policy-check-rollover"}'

The policy is attached immediately and Explain reports its policy_id right away. ISM applies the policy definition on its next job run (Compose sets the job interval to one minute, the default is five minutes). Until then the check cannot see the rollover action: it reports no policy or POLICY_UNDETERMINED, and both are allowed. Read the applied policy as the check does:

curl --fail --silent \
'http://localhost:9200/_plugins/_ism/explain/jme_policy_check_rolling-000001?show_policy=true' \
| jq '.["jme_policy_check_rolling-000001"] | {policy_id, rollover_states: [.policy.states[]? | select(any(.actions[]; has("rollover"))) | .name]}'
Applied policyCheck result
Rollover action in any stateRefused, not-allowed with target and reason; HTTP 422 NOT_ALLOWED from the job API
No rollover actionAllowed
No policy attachedAllowed
Policy metadata cannot be read (for example while .opendistro-ism-config is closed)Allowed, without claiming that the target is non-rolling

Remove the demo index and policy:

curl --silent --request DELETE http://localhost:9200/jme_policy_check_rolling-000001
curl --silent --request DELETE http://localhost:9200/_plugins/_ism/policies/jme-policy-check-rollover

Stop the infrastructure when finished:

docker compose --file docker/docker-compose.yml down

Permissions on a secured cluster​

This example runs OpenSearch without the security plugin (DISABLE_SECURITY_PLUGIN=true in docker/docker-compose.yml) and its tests use an unauthenticated client, so it does not verify the permissions below. On a secured cluster the writer's role needs, for the policy check:

  • cluster permission cluster:admin/opendistro/ism/managedindex/explain
  • index permission indices:admin/get on the target index patterns

Without the explain permission every target is allowed as policy_undetermined, and rolling targets are not refused; alert on that outcome. See OpenSearch permissions for the full permission set of the index writer. The library verifies the check against a security-enabled cluster with this role in its own integration tests.

API Reference​

All paths below are relative to the service context path shown in the local endpoint table.

Resource Service​

Method and pathBehavior
POST /api/transitdocumentsCreates a V1 transit document, stores its SearchItem and publishes JmeCreateTransitDocumentCommand; returns HTTP 201.
POST /api/transitdescisionsCreates a V1 transit decision, stores its SearchItem and publishes JmeTransitDecisionCreatedEvent; returns HTTP 201.
POST /api/v2/transitdescisionsCreates a V2 transit decision and publishes the same event type; returns HTTP 201.
GET /index-api/searchitemsSearchItem provider endpoint (role searchitem:read). Without index_major_version it returns the stored item as before. With index_major_version=1, 2 or 3 it builds the current transit decision for that schema major; other majors answer 422. See SearchItem endpoint.

The misspelled transitdescisions path is retained for compatibility with the original example.

Inspection Service​

Method and pathBehavior
GET /api/transitdocuments?goodsDescription=...Returns a page of authorized V1 transit documents whose data.goods_description contains a token with the given prefix.
GET /api/transitdocuments/by-keyword?keyword=...Uses a term query on the scalar collection data.keywords.
GET /api/transitdocuments/by-customs-office?office=...Uses a nested term query on the scalar data.customs_checks.office.
GET /api/transitdocuments/by-customs-tag?tag=...Uses a nested term query on the scalar collection data.customs_checks.tags.
GET /api/transitdocuments/by-customs-code?code=...Uses a nested term query through the single details object to data.customs_checks.details.codes.
GET /api/transitdecisions?decidedBy=...Returns a page of authorized V1 or V2 transit decisions whose data.decided_by value starts with the given prefix.
GET /api/decrees?originId=...Returns the first authorized decree whose origin.id starts with the given value, or HTTP 404.
GET /api/decreedocuments?originId=...Returns the first authorized decree document whose origin.id starts with the given value, or HTTP 404.

Paging and sorting​

The transit-document and transit-decision searches take a Spring Data Pageable, so a caller can add page, size and sort to any of them, for example ?goodsDescription=F&page=1&size=50&sort=data.goods_description,asc. Sort properties are OpenSearch field names, and the field has to be mapped as sortable in the index type. Paging uses from/size and is therefore bounded by the index's index.max_result_window (10'000 by default).

Without a sort parameter the searches return the 20 most recently created matches, i.e. origin.created descending. An explicit order matters: the result is capped at a page size, and without a sort OpenSearch returns an arbitrary slice of the matches, so a freshly indexed item can stay invisible for good once more documents match than fit on a page.

All inspection parameters are mandatory; omitting one returns HTTP 400. Prefix queries are case-insensitive. data.decided_by is mapped as a keyword, so the prefix applies to the complete field value. data.goods_description is mapped as text, so the prefix can match any analyzed token. For example, goodsDescription=F can match both Food products and Furniture.

Queries below data.customs_checks use an OpenSearch nested query with data.customs_checks as the path. The details field is a single object inside that nested document, so its codes field remains within the same nested query.

Inspection queries use SearchItemClient.searchMultiVersionWithUserAuth. A valid access token is required, and results are filtered according to the caller's roles and the authorization rules in the index type descriptors. The local inspection-internal-sys client has the jme_read role used by the walkthrough.

Process Archive Integration​

The optional Process Archive flow remains part of this portable codebase but is not enabled by the standalone local configuration. See Process Archive integration for its event flow, classes, configuration contract and ownership boundary.