Skip to content

feat(map): the map's q searches a collection's text facet values - #826

Open
MathiasVDA wants to merge 3 commits into
mainfrom
claude/project-thread-4qfh9q-820
Open

MathiasVDA wants to merge 3 commits into
mainfrom
claude/project-thread-4qfh9q-820

Conversation

@MathiasVDA

Copy link
Copy Markdown
Contributor

Requested by Mathias · project thread

What and why

Closes #820

The map's q (on /tiles/features, the tiles and the facets) now also searches a collection's tts:Facet-Text values. The shape set decides what is searchable, so no --text-properties flags are needed.

  • The full-text index covers the last property of each text facet's path in the map's shapes, besides --text-properties. This happens in make_collections for the Map reader and the full view. It is set again only when that list changes, so a new shape set takes effect without a restart, and the index is rebuilt on the next search.
  • A facet on a plain property is found by the feature's own tt:search. A facet on a longer path, such as ( ex:border ex:borderPointId ), is found with { ?x text:query (<last> "w") . ?f <before> ?x } as a UNION branch for each word. Only that property's literals match there, not the border point's own label.
  • A text facet with a tts:select, or whose path ends in an inverse, alternative or repeated step, is not searched by q. Its {key}.text= filter still works.
  • Side effect: because those properties join the full-text index, tt:search also finds their literals. This is noted in the CHANGELOG and in docs/full-text-search.md.

This is independent of #819 (it touches no facet index code), so it is based on main.

How it was tested

  • New tests/text_facet_search.rs. It finds by label, by the uopid in any case and as a prefix, and by a border point id at the end of a two-step path. It does not match the border point's own label. Label and facet words combine. The facet counts filter the same way. A shape set without the facets stops matching them, with no restart.
  • Passing: --lib, ogc, warm_up, low_zoom, text_tile_memory, search, feature_list, guide, cargo clippy --all-targets -D warnings and cargo fmt --check.

Documentation

  • The user guide (docs/guide/10-maps-and-apis.md, the q= filter) says what it searches. There is no new tested example: the guide's Station shapes have no text facet, and adding one would change other chapters' outputs.
  • docs/server.md (vector tiles, q), docs/full-text-search.md (what is indexed) and the CHANGELOG describe it

Generated by Claude Code

The full-text index covers the last property of each tts:Facet-Text path
of the map's shapes, besides --text-properties, set again when the shapes
change that list. A facet on a longer path is searched at its end with
text:query on that property, so a code such as a uopid or a border
point id finds its feature without server flags.
@MathiasVDA MathiasVDA self-assigned this Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

The audit job fails on RUSTSEC-2026-0628 (calamine 0.38, a new advisory). This PR does not cause it: the same lock file is on main, and #828 bumps calamine to 0.39. I'll merge main into this branch once #828 lands.


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Review (Reviewer 2), round 1 at b06dd8c: changes requested

must 1: test-oxigraph is red on this head and green on main (cab0f26). Four tests of crates/tripletrail-server/tests/leaks.rs fail at line 1010 (a_graph_grant_hides_the_other_graphs, a_grant_of_the_default_graph_hides_the_named_graphs, and both under a union default graph): five full-text search answers (tt:search, the text:query form with a score, and the MCP search tool) come back with different scores for the two datasets the test compares. The rows are the same, the scores are not. These tests must pass unchanged; please find what in this change makes the scores differ (the text properties being set again from make_collections is the first place to look) and fix it there, not in the test.

must 2: add a tile to text_facet_search.rs. The description says q on the tiles searches the facet values too, and the tile path with q runs its own search (text_matches, #771), but the new test only asks /tiles/features and the facets. One tile with q= a facet value at the end of the two-step path, and one that must not match, is enough.

What holds otherwise:

  • The shape set decides what is searchable, for any shape set: nothing here is specific to one application.
  • text_facet_step leaves out a facet with a tts:select and a path that does not end in a plain property, and the docs say so.
  • Docs: guide chapter 10, docs/server.md, docs/full-text-search.md and the CHANGELOG, including the side effect that tt:search finds these literals too.

nit: index_text_facets keeps what it last set in text_facets. If the text properties are set from elsewhere after that (a dataset option changed over the admin API), the facet properties are dropped from the index and this cache still says they are set. Either say in the comment why that cannot happen, or set them from one place.

audit is red for the reason it is red on main (fixed by #828); a merge of main after #828 clears it.


Generated by Claude Code

@MathiasVDA MathiasVDA added the review:changes Reviewer asks for changes label Dec 3, 2026 — with Claude
The text facets of the shapes generated from the data depend on every
graph, and which properties the full-text index holds changes its scores,
also for a caller who may read only some graphs: the leak suite saw
different scores. Only the dataset's own shape set and pack now add
properties, the q filter's path branches use indexed properties only, and
the properties are set again when the engine's were set since. Adds a tile
to the test.

Closes #820

Copy link
Copy Markdown
Contributor Author

Round 1 addressed in 49527bf.

must 1: the cause was the generated shapes. Without a shape set, the map's collections come from shapes generated from every graph, so the text facets (and the properties added to the full-text index) differed between the two compared datasets, and with them the scores. Now only the dataset's own shape set and pack add properties (shapes::declared, no generated layer), and the q filter's path branches use indexed properties only. leaks.rs passes unchanged on both stores (TRIPLETRAIL_STORE=oxigraph 5/5, default 5/5). Docs, guide and CHANGELOG say "own shape set or shape pack".

must 2: text_facet_search.rs now asks a zoom-14 tile with q=BP42 (two-step path, shows the feature), q=Magnor (other literal of that node, does not), and without q.

nit: index_text_facets now also sets the properties again when the engine's properties no longer hold the facet properties, so a cache left behind cannot hide them.

I'll merge main once #828 lands, for audit.


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Review (Reviewer 2), round 2 at 49527bf: approved, waits for CI and a merge of main

  • must 1 done, in the code and not in the test: only the shape set the dataset was given (its pack and its own set, shapes::declared) adds properties to the full-text index; shapes generated from the data add none. The q filter's path branches use indexed properties only, so the two stay in step. leaks.rs is unchanged; I merge only with test-main and test-oxigraph green on the final head.
  • must 2 done: the test asks a zoom-14 tile without q, with the value at the end of the two-step path (shown) and with the other literal of that node (not shown).
  • nit taken: the properties are set again when the engine no longer holds them.
  • Docs, guide and CHANGELOG now say "own shape set or shape pack".

audit needs main (#828 is merged). Please merge main into the branch (no rebase).


Generated by Claude Code

@MathiasVDA MathiasVDA added review:approved Reviewer approved and removed review:changes Reviewer asks for changes labels Dec 3, 2026 — with Claude

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review:approved Reviewer approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Map search (q) does not search a collection's Facet-Text facets (e.g. codes such as a uopid)

1 participant