Class AiSearchWebScript

java.lang.Object
org.springframework.extensions.webscripts.AbstractWebScript
fr.becpg.repo.web.scripts.remote.AbstractEntityWebScript
fr.becpg.repo.web.scripts.remote.ai.AiSearchWebScript
All Implemented Interfaces:
org.springframework.extensions.webscripts.WebScript

public class AiSearchWebScript extends AbstractEntityWebScript

AI-oriented entity search (/becpg/remote/ai/search).

Reuses the standard search dispatch (AbstractEntityWebScript.findEntities(org.springframework.extensions.webscripts.WebScriptRequest, java.lang.Integer, boolean)) — simple full-text search via ?query=, or an advanced criteria search via a POST JSON body — but returns a compact result (nodeRef, type, name, code) instead of full entity serialization, to keep AI token usage low. Search runs as the authenticated user, so tenant and permission filtering are inherited.

Optional fields projection — performance-conscious by design. When ?fields=ns:p1,ns:p2 is supplied, each hit also carries those properties under a fields object. To keep the cost bounded and predictable we read the node's property map once (NodeService.getProperties(org.alfresco.service.cmr.repository.NodeRef)) and return the requested plain property values as-is: we deliberately do not resolve associations, characteristic names or datalists here (that is the expensive part of full serialization). The number of projected fields is capped (MAX_PROJECTION_FIELDS) and results are bounded by maxResults. For richer (assoc-resolved) data the caller fetches the single entity on demand.

Author:
matthieu
  • Field Details

    • DEFAULT_MAX_RESULTS

      private static final int DEFAULT_MAX_RESULTS
      See Also:
    • MAX_PROJECTION_FIELDS

      private static final int MAX_PROJECTION_FIELDS
      Hard cap on the number of projected fields, to keep the per-hit cost bounded.
      See Also:
  • Constructor Details

    • AiSearchWebScript

      public AiSearchWebScript()
  • Method Details

    • executeInternal

      protected void executeInternal(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse resp) throws IOException

      executeInternal.

      Specified by:
      executeInternal in class AbstractEntityWebScript
      Parameters:
      req - a WebScriptRequest object
      resp - a WebScriptResponse object
      Throws:
      IOException - if any.
    • parseFields

      private Set<org.alfresco.service.namespace.QName> parseFields(String fieldsParam)
      Parses a comma-separated fields parameter into a bounded set of property QNames. Unknown prefixes / malformed tokens are skipped (best-effort), and the set is capped to keep the cost bounded.