adityamparikh opened a new issue, #240:
URL: https://github.com/apache/solr-mcp/issues/240

   "Find shows like Dark" or "more books like this one" is a common request, 
and Solr answers it with More Like This (MLT), with no vectors or embedding 
model. Today a client can only reach MLT by writing local params into 
`search`'s `q`:
   
   ```
   {!mlt qf=description_t mintf=1 mindf=1}0553573403
   ```
   
   That is the kind of nested-syntax string #209 argues against for eDisMax. It 
also hides a trap: Lucene's defaults (`mintf=2`, `mindf=5`) return nothing on 
small collections, so a client that leaves them out gets zero results with no 
hint why.
   
   MLT isn't a variation on a search. It replaces the query ("documents like 
this one" instead of "documents matching these words"), so it gets its own tool 
rather than more parameters on `search`. The tool name maps directly onto the 
user's request, and there's no "don't combine `query` with `similarTo`" rule to 
explain.
   
   ## Proposal
   
   A read-only tool, `find-similar`:
   
   | Parameter | Required | Notes |
   |---|---|---|
   | `collection` | yes | |
   | `id` | yes | uniqueKey value of the source document |
   | `similarityFields` | yes | text fields to compare on, e.g. 
`["description", "genres"]`; sent as MLT `qf` |
   | `filterQueries` | no | applied to the results, e.g. `platform:Netflix`, so 
"like Dark, but on Netflix" works |
   | `rows` | no | default 10 |
   
   - The server sends `q={!mlt qf=... mintf=1 mindf=1}<id>`, so the client 
never handles MLT's thresholds.
   - The source document is excluded from the results (Solr's behaviour; the 
test pins it).
   - The response reuses `SearchResponse`, so no new record and no 
`SolrNativeHints` change.
   - `@PreAuthorize("isAuthenticated()")` and `readOnlyHint = true`, like 
`search`.
   - An unknown `id` returns an error that says the document wasn't found in 
that collection, in the style of #212's actionable errors, rather than Solr's 
raw MLT message.
   
   Checked by hand on a 2-shard SolrCloud 9.9.0 (`solr:9.9.0-slim`): `{!mlt 
qf=description_t mintf=1 mindf=1}<id>` on the books sample returned the other 
books about noble houses and court politics, and excluded the source document.
   
   ## `search-collection` prompt
   
   The prompt's step 4 already covers zero results (relax filters one at a 
time, broaden the query). Add three short steps:
   
   - Before step 2: if the question depends on earlier conversation ("anything 
cheaper by the same author?"), rewrite it as a standalone question first and 
build `q`/`fq` from that.
   - When results are few or off-topic because of wording ("court politics" vs 
"noble houses"), try one or two rephrasings with synonyms before relaxing 
filters.
   - For "more like this one", find the document's id with `search`, then call 
`find-similar`.
   
   ## Tests
   
   Following the split Spring AI uses for its own RAG tests: mocks for the 
request wiring, real Solr for what comes back.
   
   - [ ] Unit: the exact `SolrQuery` parameters (`q` with `qf`, `mintf=1`, 
`mindf=1`; `fq`; `rows`).
   - [ ] Integration via `McpClientIntegrationTestBase` on `shows.json`: 
`find-similar` for a known show returns expected related shows near the top and 
excludes the source document; `filterQueries` narrow the results; an unknown id 
returns the "not found" error.
   - [ ] Integration: pin which field properties MLT needs on SolrCloud (stored 
text fields), so the parameter description stays accurate.
   - [ ] `listToolsReturnsExpectedTools` and `toolsExposeBehaviorHints` include 
`find-similar` as read-only.
   - [ ] Passes in the Solr compatibility matrix (8.11 to 10).
   
   ## Notes
   
   - MLT compares terms, not meaning. Semantic search from free text, with no 
source document, is #64.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to