Problem
createFullTextFilterHandler (packages/bindx/src/dataview/filterHandlers.ts, v0.1.53) turns the DataGrid search box into one condition per searchable field, each with the whole query:
const conditions = fieldPaths.map(fieldPath => buildNestedWhere(fieldPath, buildTextCondition(artifact.mode, artifact.query)))
return { or: conditions }
So a query of several words only matches when one field contains all of them, in that order. Typical searches that therefore return nothing:
Jan Novák on a contact grid searching firstName and lastName
Alza Praha on a company grid searching name and city
Novák Instagram where the words sit in the row and in a related record
Users type these all the time (first name plus surname above all) and read the empty result as "the search is broken".
Proposal
In contains mode, split the query on whitespace and require every word to match some field:
const words = artifact.query.trim().split(/\s+/).filter(Boolean)
// { and: words.map(word => ({ or: fieldPaths.map(path => buildNestedWhere(path, { containsCI: word })) })) }
- one word gives exactly today's
{ or: [...] }, so single-word searches are unchanged
- word order does not matter (
Novák Jan works too)
- the other modes (
startsWith, endsWith, equals, notContains) keep matching the whole query, since splitting changes their meaning
SelectDataView uses the same handler, so select pickers would benefit as well
Context
Found in a CRM on bindx 0.1.52 (list search over contacts and companies). We carry this change as a local bun patch of @contember/bindx until it lands upstream.
Problem
createFullTextFilterHandler(packages/bindx/src/dataview/filterHandlers.ts, v0.1.53) turns the DataGrid search box into one condition per searchable field, each with the whole query:So a query of several words only matches when one field contains all of them, in that order. Typical searches that therefore return nothing:
Jan Novákon a contact grid searchingfirstNameandlastNameAlza Prahaon a company grid searchingnameandcityNovák Instagramwhere the words sit in the row and in a related recordUsers type these all the time (first name plus surname above all) and read the empty result as "the search is broken".
Proposal
In
containsmode, split the query on whitespace and require every word to match some field:{ or: [...] }, so single-word searches are unchangedNovák Janworks too)startsWith,endsWith,equals,notContains) keep matching the whole query, since splitting changes their meaningSelectDataViewuses the same handler, so select pickers would benefit as wellContext
Found in a CRM on bindx 0.1.52 (list search over contacts and companies). We carry this change as a local
bun patchof@contember/bindxuntil it lands upstream.