Skip to content

docs: add a first-collection tutorial teaching schema design - #184

Open
adityamparikh wants to merge 3 commits into
apache:mainfrom
adityamparikh:docs/first-collection-tutorial
Open

docs: add a first-collection tutorial teaching schema design#184
adityamparikh wants to merge 3 commits into
apache:mainfrom
adityamparikh:docs/first-collection-tutorial

Conversation

@adityamparikh

Copy link
Copy Markdown
Contributor

What

Adds docs/tutorial.md — a hands-on walkthrough taking a reader from an empty Solr to a
designed, queryable collection, entirely through natural-language conversation with an
assistant. Linked from the README documentation index.

Why

The docs cover how to connect a client and what each tool does, but nothing explains
why field types decide which questions are answerable. That gap matters here more than in
a normal Solr context: the assistant will happily index anything schemaless, and the user has
no obvious signal that they've traded away faceting and sorting until a question quietly
fails.

So the tutorial indexes the same 61-document dataset twice — once letting Solr guess, once
choosing types on purpose — and puts the two side by side:

schemaless designed
Documents indexed 61 of 61 61 of 61
platform type text_general string + docValues
imdb_rating type pdoubles (multi-valued) pdouble
"breakdown by platform" fails Netflix 20, Amazon Prime Video 20, HBO Max 7, …

Same data, same question, same tool. The only difference is that someone decided what the
fields meant.

Verification

Every factual claim was checked end-to-end against Solr 9 in SolrCloud mode, driven through
the MCP server over STDIO — not written from what the tool signatures imply:

  • the guessed types (text_general, pdoubles, plongs) and the array-wrapped documents
  • all eight search examples and their result counts (1, 2, 20, 31, 15, status 33/28, top-rated
    Game of Thrones 9.2, combined 39)
  • the facet buckets quoted in the text
  • check-health reporting 61 docs, and get-collection-stats exposing the cache hit ratios
    the tutorial invites the reader to ask about

Known issues, documented rather than hidden

A reader following the steps will hit both of these, so the tutorial names them and links the
issues instead of quietly routing around them:

If either is fixed, the corresponding section should be trimmed — they're marked clearly
enough to find.

Notes for review

  • Uses the raw shows.json from src/test/resources/ via its GitHub URL. Referencing a test
    resource from user docs is a little irregular; happy to move the dataset somewhere more
    deliberate if preferred.
  • Docker examples follow the existing docs/clients/*.md convention of a locally built image
    rather than a registry reference, since no official image is published yet.
  • **/*.md is RAT-excluded and the existing docs/*.md carry no license header, so this
    follows suit.

Adds docs/tutorial.md, a hands-on walkthrough that takes a reader from an
empty Solr to a designed, queryable collection entirely through natural
language.

The tutorial indexes the same 61-document dataset twice: once schemaless,
once with types chosen deliberately. The schemaless pass succeeds and then
fails to answer an ordinary question, which motivates the second pass. That
contrast is the point — the project documents how to call the tools, but not
why field types decide which questions are answerable.

Every claim is verified end-to-end against Solr 9 in SolrCloud mode, driven
through the MCP server over STDIO: the guessed types (text_general, pdoubles,
plongs), the array-wrapped documents, all eight search examples with their
result counts, the facet buckets, and the introspection output.

Two current defects are documented in a Known issues section rather than
worked around silently, since a reader following the steps will meet both:

- apache#182 — faceting a query that matches nothing throws
  ClassCastException, which is what the schemaless pass hits
- apache#183 — collections share the _default configset, so schemaless
  guesses leak forward; this is why the tutorial resets Solr midway

Also links the tutorial from the README documentation index.

Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
Rewrites Step 2 for the behaviour after apache#185. The schemaless facet no longer
throws; it returns numFound=61 with facets.platform={} — the query succeeds
and simply has no breakdown to give.

That is a better illustration of the point than the exception was. A stack
trace reads as "something is broken"; a successful query with an empty answer
is precisely the trap schemaless sets, because nothing tells you the data is
fine and the field type is at fault.

Also drops the apache#182 entry from Known issues, and sharpens the platform row:
searching platform:prime matches all 20 Amazon Prime Video shows, which shows
concretely why tokenizing a category is wrong.

Re-verified against a build of the apache#185 branch over the MCP protocol: the
empty facet, the 20-hit token match, the three guessed types, and the
array-wrapped documents.

Depends on apache#185.

Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
@adityamparikh

Copy link
Copy Markdown
Contributor Author

Updated to assume #185 is merged — this PR now depends on it.

With the empty-facet fix in place, Step 2 no longer throws. The schemaless facet returns:

{ "numFound": 61, "documents": [], "facets": { "platform": {} } }

Which is a better illustration of the point than the exception was. A stack trace reads as
"something is broken and it isn't your fault." A query that succeeds against 61 documents and
returns an empty breakdown is exactly the trap schemaless sets: nothing tells you the data is
fine and the field type is the problem.

Changes:

  • Step 2 rewritten around the empty result rather than the crash
  • the #182 entry dropped from Known issues (#183 and the sortClauses note remain)
  • the platform row sharpened with a concrete consequence — searching platform:prime
    matches all 20 Amazon Prime Video shows, so the category has stopped being one value

Re-verified against a build of the #185 branch, driven over the MCP protocol: the empty facet,
the 20-hit token match, the three guessed types (text_general / pdoubles / plongs), and
the array-wrapped documents.

If #185 is rejected or reworked, say so and I'll restore the previous wording — the earlier
revision documented the exception and is still in this branch's history.

@adityamparikh

Copy link
Copy Markdown
Contributor Author

Correction to my earlier comment: this PR's dependency is #175, not #185. #185 was a duplicate of #175 and has been closed; #175 is the PR that makes Step 2 return an empty facet rather than throwing. Nothing in the tutorial text changes — only the PR number this depends on.

The note quoted the sort clause shape as {"item": ..., "order": ...}. apache#164
replaces that map with a typed SortClause record keyed on "field", so the
example would have become wrong the moment that PR merged — and this tutorial
already carries one merge-order dependency.

The underlying caveat holds either way: undeclared arguments are dropped rather
than rejected, so a misnamed one reads as a query that quietly ignored part of
the request. Keeps that, drops the key names, and points at the client's tool
inspector as the durable way to check.

Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
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