adityamparikh opened a new pull request, #291:
URL: https://github.com/apache/solr-mcp/pull/291

   Closes #209.
   
   ## Summary
   
   Adds two optional parameters to the `search` tool. They cover the two places 
where an agent struggles most: every stored field comes back, and searching 
several text fields means writing local params by hand.
   
   | Param | Solr | Effect |
   |---|---|---|
   | `fields` | `fl` | Return only these fields. `score` is always kept, so 
`maxScore` still works. |
   | `queryFields` | `qf` + `defType=edismax` | Search plain words across these 
fields, with optional boosts. |
   
   ```diff
    search(collection, query, filterQueries, facetFields, sortClauses, start, 
rows
   +       , fields, queryFields)
   +  if queryFields has an entry
   +    if query starts with "{!"  -> reject before sending   # eDisMax would 
search "{!...}" as text
   +    qf = join(queryFields, " "); defType = edismax
   +  if fields has an entry
   +    fl = fields                                          # set before 
setIncludeScore appends ",score"
      fl += score
      ...
    withRemediationHint
   -  "undefined field" | "field can't be found"             -> get-schema hint
   +  "undefined field" | "field can't be found"
   +    | "is not a valid field name"                        -> get-schema hint 
  # bad qf field was getting the Lucene-syntax hint
   ```
   
   - When both are omitted, the request is the same as before.
   - A 7-argument `search(...)` overload without `@McpTool` keeps the ~80 
existing Java callers compiling. It has the same `@PreAuthorize` as the tool 
method.
   - The tool description, the `query` parameter description and the 
`search-collection` prompt now teach `queryFields` instead of `{!edismax 
qf=...}` or `(title:foo OR description:foo)`. They also tell the agent to pass 
`fields` to keep responses small.
   - `docs/tutorial.md` gets two example asks. `THREAT_MODEL.md` lists the new 
parameters in the `search` rows.
   
   Out of scope, with the reasons in #209: `mm`, `q.op`, facet limits and facet 
queries, and highlighting.
   
   ## Evidence
   
   - **Before:** `search(fields=["id"])` had no `fields` parameter; every 
document came back with all stored fields. 
`queryFields=["definitely_not_a_field"]` (written by hand as `qf`) returned the 
Lucene-syntax hint.
     **After** (real Solr, `SearchServiceIntegrationTest`):
     ```text
     searchWithFieldsReturnsOnlyThoseFieldsAndScore
       search("name:kings", fields=["id"])            -> doc keys == {id, 
score}, maxScore != null   ✔
     searchWithQueryFieldsSearchesOnlyThoseFields
       search("kings", queryFields=["name"])          -> [book002]              
                     ✔
       search("kings", queryFields=["author_ss"])     -> numFound 0             
                     ✔
     searchWithUndefinedQueryFieldReturnsGetSchemaHint
       search("kings", queryFields=["definitely_not_a_field"]) -> get-schema 
hint, no cause          ✔
     ```
   - Over MCP on stdio and http 
(`McpClientIntegrationTestBase.searchWithQueryFieldsAndFieldsThroughMcp`): 
`query="apocalyptic"`, `queryFields=["title","description"]`, 
`fields=["title"]` finds Fallout, and every document has exactly `{title, 
score}`.
   - `SearchServiceTest` pins the request: `fl=*,score` and no `qf`/`defType` 
by default; `fl=id,name,score`; blank entries are dropped; `{!...}` with 
`queryFields` throws before `solrClient.query` is called; `{!...}` without 
`queryFields` is sent unchanged.
   - `./gradlew spotlessApply build`: 472 tests, 0 failures, 0 skipped.
   
   ## Merge Danger
   
   **Door:** two-way
   
   Both parameters are additive and optional. Reverting removes them, and no 
stored data or config depends on them.
   
   **Blast Radius:** `search`
   
   Only requests that pass the new parameters change. The one new rejection, 
`queryFields` with a `{!...}` query, applies only to calls that use 
`queryFields`, which no client can send today.
   
   🤖 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]

  • [PR] feat(search): add fields ... adityamparikh (via GitHub) via issues

Reply via email to