project-lux / lux-marklogic

Code, issues, and resources related to LUX MarkLogic
Other
3 stars 2 forks source link

Only calculate search result scores when necessary #123

Open brent-hartwig opened 2 months ago

brent-hartwig commented 2 months ago

Problem Description: Searches that do not require scores are slower than they need to be. This optimization was identified during the CTS / Optic API comparison effort. Note that the value of this optimization will likely be fairly low so long as our default sort uses scores --a different topic for discussion.

Expected Behavior/Solution: When scores are not needed, instruct MarkLogic not to calculate them. At present, scores are only used for two search result sort options.

Requirements: More of a design than requirements:

Needed for promotion: If an item on the list is not needed, it should be crossed off but not removed.

UAT/LUX Examples:

Verification would likely requiring reviewing the generated query, which one can do using https://github.com/project-lux/lux-marklogic/blob/main/scripts/getCtsQueryForSearchCriteria.js within QC by also passing in an instance of SortCriteria into the call to processSearchCriteria. Or consume the endpoint and get the query from the logs.

Scenarios to test include:

  1. Search without sort criteria, thereby applying the default sort, which is relevance. Expectation: score-zero option is not present.
  2. Explicitly request sort by relevance ("Relevance" sort option). Expectation: score-zero option is not present.
  3. Randomize the results by score ("Shuffle Results" sort option). Expectation: score-zero option is not present.
  4. Search with any of the other sort options. Expectation: score-zero option is present.

Dependencies/Blocks:

Related Github Issues:

None

Related links:

None

Wireframe/Mockup:

Not needed