Skip to content

facet.matches applies one pattern to every facet in a multi-facet request #1

Description

@njakobsen

FieldFacet#to_params emits the :matches option as a global facet.matches param:

params[:"facet.matches"] = @options[:matches] if @options[:matches]

Solr scopes an unqualified facet param to every facet.field in the request, so when one request facets several fields with different patterns, one pattern wins and applies to all of them. Demonstrated against Solr 8.11.4 with two facet fields and one pattern meant for the first: the second field returned no rows under the global param, and the correct rows once each field carried its own f.<field>.facet.matches.

Sunspot already solves this for facet.prefix through qualified_param; :matches should be emitted the same way, with a spec asserting that two facets in one request keep distinct patterns.

Downstream today this is latent — Glint builds every facet's pattern from the same typed prefix, so the patterns coincide — but it bites the first time two facets in a request legitimately differ.

Two behaviours worth documenting while in the file, since both have cost real debugging time: the pattern is a Java regex (not Ruby — accepting a Regexp object would invite dialect bugs, so the string-only API is worth keeping and stating), and Solr matches it against the entire facet term, so an unanchored search needs explicit .*.

🤖 Generated with Claude Code

https://claude.ai/code/session_0162sTEdS4eZUe2oi2JioByV

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions