User tests: Successful: Unsuccessful:
Smart Search's "Relevance" ordering sums the raw weights stored in
#__finder_links_terms. That weight is calculated at index time from the term
frequency, the length of the term and the multiplier of the context the term
appeared in. It carries no information about how rare the term is, so a match
on a very common word counts for exactly as much as a match on a highly
distinctive one. In a multi-word query the common words therefore drown out the
words that actually identify what the user is looking for.
This PR scales every match by the inverse document frequency (IDF) of its term:
LN(1 + totalIndexedLinks / ti.links)
ti.links is the per-term link counter the indexer already maintains in
#__finder_terms, so no schema change and no reindex is required — the data
this needs is already there on every existing site.
Two small notes:
LN() is used rather than LOG(), because LOG() is base 10 on PostgreSQLLN() is the natural logarithm on both.* 1.0 in the ratio is load bearing: both operands are integers andAlso included:
tests/System/integration/site/components/com_finder/Relevance.cy.js,tests/System/integration/site/components/com_finder/Search.js is renamed toSearch.cy.js. The Cypress specPattern in cypress.config.dist.mjs only*.cy.{js,jsx,ts,tsx}, so that existing Smart Search test has neverWhile implementing and testing this, it turned out that there are additional bugs in the system where the counter in the terms table is not correctly updated upon deletion. However this is outside of the scope of this PR and will be fixed in another PR. There are also other changes planned for Smart Search which affect indexing results, but again, those are outside of the scope of this PR and will have to wait a bit.
zorbex once.zorbex five times and quilon once.zorbex once and quilon four times.zorbex quilon and set the ordering to "Relevance".zorbex and check the ordering again.Alternatively, run the new system test:
npx cypress run --spec tests/System/integration/site/components/com_finder/Relevance.cy.js
Searching for zorbex quilon puts "Decoy" above "Target". It holds six matching
words in total against the target's five, and because every match is worth the
same regardless of how common its term is, the higher raw count wins — even
though all but one of the decoy's matches are on the word that appears all over
the site and tells you nothing.
Searching for zorbex quilon puts "Target" above "Decoy". Its matches are
concentrated in the rare term, which is the one that distinguishes it from the
rest of the corpus.
Searching for zorbex alone is unchanged: a single-term query applies one
uniform factor to every match, so plain frequency ordering still applies and
"Decoy" is still first.
Please select:
Documentation link for guide.joomla.org:
No documentation changes for guide.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed
| Status | New | ⇒ | Pending |
| Category | ⇒ | Front End com_finder JavaScript Unit Tests |
| Labels |
Added:
Unit/System Tests
PR-6.2-dev
|
||