Adriano Machado created CAMEL-24396:
---------------------------------------

             Summary: website: configure Algolia index for search result 
deduplication and faceting
                 Key: CAMEL-24396
                 URL: https://issues.apache.org/jira/browse/CAMEL-24396
             Project: Camel
          Issue Type: Improvement
            Reporter: Adriano Machado


The {{apache\_camel}} Algolia index has neither {{attributeForDistinct}} nor 
{{attributesForFaceting}} configured. As a result, search result 
de\-duplication and sub\-project exclusion both have to run in the browser, 
after Algolia has already chosen which hits to return. Configuring them at the 
index level would remove that constraint and let us delete most of the 
client\-side logic in {{antora\-ui\-camel/src/js/08\-docsearch.js}}.

This requires Algolia admin access \(or DocSearch crawler config access\), so 
it cannot be done from the camel\-website repository.

h2. Evidence

Queried against the live index with the public search key:

{code}
POST /1/indexes/apache\_camel/query  {"query":"kamelet","hitsPerPage":20}
\-> nbHits 3121, 20 hits returned, spanning only 4 distinct parent pages
   \(16 of the 20 were anchors on components/4.22.x/kamelet\-component.html\)
{code}

* Adding {{"distinct": true}} to the query changed nothing, which confirms 
{{attributeForDistinct}} is unset. {{distinct}} is a no\-op without it.
* A {{{"facets": \["\*"\]}}} query returned no facets at all, confirming 
{{attributesForFaceting}} is unset, so {{facetFilters}} cannot be used to 
exclude sub\-projects server side.

h2. Why this matters

Because both filters run client side, they operate on an already\-truncated 
window of hits. Distinct parent pages remaining after applying the sub\-project 
exclusion:

|| query || hitsPerPage 20 || hitsPerPage 50 || hitsPerPage 100 ||
| kamelet | 2 pages | 3 pages | 3 pages |
| timer | 1 page | 7 pages | 16 pages |
| rest dsl | 7 pages | 16 pages | 25 pages |

The site currently over\-fetches \({{hitsPerPage: 50}}\) purely to compensate. 
With server\-side {{distinct}} the de\-duplication happens before the window is 
applied, so the default of 20 would return 20 genuinely distinct pages and the 
over\-fetch could be removed.

h2. Proposed change

In the DocSearch crawler config / index settings:

{code:json}
{
  "attributeForDistinct": "url\_without\_anchor",
  "distinct": true,
  "attributesForFaceting": \["filterOnly\(url\)"\]
}
{code}

Note that {{url\_without\_anchor}} needs to be confirmed present on the 
records; the hits currently expose {{url}}, {{hierarchy}}, {{content}}, 
{{version}} and {{objectID}}. If it is absent, the crawler {{recordProps}} need 
to emit it, or {{attributeForDistinct}} should point at an equivalent 
anchor\-free attribute.

h2. Client\-side code this would replace

In {{antora\-ui\-camel/src/js/08\-docsearch.js}}:

* {{limitHitsPerPage}} / {{MAX\_HITS\_PER\_PAGE}} \- fully replaced by 
{{attributeForDistinct}}.
* {{HITS\_PER\_PAGE = 50}} \- can drop back to the DocSearch default.
* {{isSubProjectUrl}} / {{EXCLUDED\_SUBPROJECTS}} \- replaced by a 
{{facetFilters}} entry in {{indices\[0\].searchParameters}}.

{{sortByCoreDocs}} would remain client side, or better, move into the index as 
a custom ranking attribute.

h2. Context

This came out of the DocSearch v5 migration in camel\-website PR #1729. The 
previous implementation \({{src/js/vendor/algoliasearch.bundle.js}}\) 
hand\-rolled all of this against the raw Algolia client. The v5 rewrite 
initially dropped it entirely; it has since been reinstated in adapted form, 
but the index\-level fix is the durable one.





--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to