Skip to content

feat(search): keep summary with latLong in semantic item format - #217

Merged
kiivihal merged 3 commits into
mainfrom
feat/semantic-geo-summary
Nov 11, 2026
Merged

kiivihal merged 3 commits into
mainfrom
feat/semantic-geo-summary

Conversation

@zemyatin

Copy link
Copy Markdown
Collaborator

Why

The DIW asks hub3 for records with itemFormat=semantic, and map coordinates never arrive in that format. The data is there: it is in Elasticsearch and it shows up in the default format.

It gets lost on the way:

  • The coordinates sit on nave:DelvingResource.
  • The EDM 5.2.6 record definition gives that node no rdf:about, so in every Narthex-mapped record it is a blank node that no triple points at.
  • GenerateSemantic builds the tree by walking outward from the entry URI, so it never reaches that node and drops it without a word.

What changes

  1. hub3/fragments/resource.go: ResultSummary.AddEntry gets a latLong case, so an entry tagged latLong fills in summary.latLong.
  2. hub3/server/http/handlers/search.go: both semantic paths (search list and single record) now build the summary before Resources is cleared, and keep it instead of setting it to nil. The summary is built from every resource in the record, so it reaches the blank node the tree walk misses.

The result: summary.latLong appears in semantic responses for every Narthex-mapped dataset, with no mapping changes needed.

Payload. Fields, JSONLD, ProtoBuf and Item are still cleared, so the "reduce payload" intent stays. The summary is the one exception, and it is small.

Alternatives considered

  • Putting the unreached nodes in @graph: they would become visible, but the client would have to guess which record each one belongs to.
  • Fixing the mappings (give the place an rdf:about and link it with dcterms:spatial/@rdf:resource, as enb-111-objecten already does): that is per-dataset work across hundreds of old mappings, and it can never fix nave:DelvingResource, because the record definition has no slot for one.

Open questions

  1. Is keeping the summary in the semantic format acceptable, or would you rather solve this inside GenerateSemantic?
  2. Related items (more-like-this) in the semantic format still get no summary, so no coordinates. The comment in the MLT block ("Related items have same structure as main item") is no longer true. Should related items get a summary too, or should the comment change?
  3. There is no test for the search.go half, because hub3 has nothing that tests the itemFormat responses. The proof so far is the live API on a local hub3.

Testing

  • New unit test: an entry tagged latLong ends up in summary.latLong.
  • go test ./hub3/fragments/ ./hub3/server/http/handlers/ passes, rebased on the latest dev-v0.5.
  • Checked by hand against a local hub3: semantic search and detail responses carry summary.latLong for a Narthex-mapped dataset.

zemyatin and others added 2 commits October 30, 2026 09:18
More-like-this items now have the same {meta, semantic, summary} as the
main item, so they get latLong as well. Built by
FragmentGraph.SemanticRelatedItem, which has a test.
@kiivihal

Copy link
Copy Markdown
Member

Review: approve, with two changes.

Checked: the summary is built before Resources is cleared in both semantic paths, which is the order it needs. go test ./... passes; the fragments suite needs Elasticsearch through testcontainers (DOCKER_HOST set to a Podman socket works). The new latLong spec fails without the fix and passes with it.

Changes:

  1. Base branch. This targeted dev-v0.5, but production builds main, and dev-v0.5 has nothing main lacks (it is 17 commits behind). The PR merges cleanly onto main, so it should go there.
  2. Related items (your question 2). Pushed 2d5cc30: more-like-this items in the semantic format now get the same {meta, semantic, summary} as the main item, so they carry latLong too. Built by FragmentGraph.SemanticRelatedItem, with a test that fails without it; the comment in the MLT block is updated.

On your other questions: keeping the summary is the right call. GenerateSemantic could only place the blank node by guessing, and the summary is small. The missing test for itemFormat responses is a gap in hub3 as a whole and need not hold this up.

@kiivihal
kiivihal changed the base branch from dev-v0.5 to main November 11, 2026 16:02
# Conflicts:
#	hub3/fragments/semantic_test.go
@codecov

codecov Bot commented Nov 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 36.14%. Comparing base (99a31d8) to head (31a418e).

Files with missing lines Patch % Lines
hub3/server/http/handlers/search.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #217      +/-   ##
==========================================
+ Coverage   36.10%   36.14%   +0.04%     
==========================================
  Files         412      412              
  Lines       38154    38157       +3     
==========================================
+ Hits        13776    13793      +17     
+ Misses      24376    24362      -14     
  Partials        2        2              
Flag Coverage Δ
unittests 36.14% <66.66%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kiivihal
kiivihal merged commit d3eaa11 into main Nov 11, 2026
5 of 6 checks passed
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.

2 participants