bpmn-io / diagram-js

A toolbox for displaying and modifying diagrams on the web.
MIT License
1.71k stars 418 forks source link

fix(search): prioritize start of word and exact match more #953

Closed nikku closed 5 days ago

nikku commented 5 days ago

Test via npx @bpmn-io/sr bpmn-io/bpmn-js -l bpmn-io/diagram-js#search-start

Proposed Changes

This prioritizes start of term and exact matches more aggressively.

This yields more substantial results in large popup (append) menus:

capture SO2PNd_optimized

This yields better search results when querying larger data pools, where exact matches would otherwise de-prioritized:

capture 5sTQ3Y_optimized

Related to https://github.com/camunda/camunda-modeler/issues/4122, https://github.com/camunda/camunda-modeler/issues/3439.

Checklist

To ensure you provided everything we need to look at your PR:

barmac commented 5 days ago

I added the sr script to the top comment, and am looking into this right now.

barmac commented 5 days ago

While searching for the start of the word works better with this PR, the exact match with spaces is moved down:

This PR:

image

Current:

image

barmac commented 5 days ago

I can reproduce https://github.com/camunda/camunda-modeler/pull/4711#issuecomment-2491044304 in this PR too.

nikku commented 5 days ago

@barmac Thanks for your tests! I think we get to something reasonable, one test at a time. Check my latest updates on this branch out or the following capture that shows this is fixed: We now score tokens by length, too, to prioritize longest matches. Also we de-prioritize non-matches:

capture i7bkrt_optimized

barmac commented 5 days ago

Great improvement