Class EmbeddingChunkRestController


@RestController @RequestMapping("/admin/rest/settings/embedding-chunks") @PreAuthorize("@WebjetSecurityService.hasPermission(\'embeddingChunks\')") public class EmbeddingChunkRestController extends DatatableRestControllerV2<EmbeddingChunkEntity,Long>
REST controller for managing RAG embedding chunks via the admin datatable interface. Provides CRUD operations, document indexing actions, and statistics endpoints. Requires 'embeddingChunks' permission.
  • Constructor Details

  • Method Details

    • getDomainId

      protected int getDomainId()
      Uses shared domain zero for the Markdown tab and the current domain for other entity types.
      Overrides:
      getDomainId in class DatatableRestControllerV2<EmbeddingChunkEntity,Long>
      Returns:
      storage domain selected by the request entity type
    • getAllItems

      public org.springframework.data.domain.Page<EmbeddingChunkEntity> getAllItems(org.springframework.data.domain.Pageable pageable)
      Loads chunks for the requested source type after preparing the vector schema. Markdown retrieval uses shared configuration and storage.
      Overrides:
      getAllItems in class DatatableRestControllerV2<EmbeddingChunkEntity,Long>
      Parameters:
      pageable - requested page and sort order
      Returns:
      matching chunks, or an empty page when the type is invalid or the vector store is unavailable
    • findByColumns

      public org.springframework.data.domain.Page<EmbeddingChunkEntity> findByColumns(Map<String,String> params, org.springframework.data.domain.Pageable pageable, EmbeddingChunkEntity search)
      Applies column filtering in the shared configuration context for Markdown chunks.
      Overrides:
      findByColumns in class DatatableRestControllerV2<EmbeddingChunkEntity,Long>
      Parameters:
      params - request parameters including the source entity type
      pageable - requested page and sort order
      search - entity holding example-search values
      Returns:
      matching chunks, or an empty page for an invalid source type
    • getSearchProperties

      public org.springframework.data.domain.ExampleMatcher getSearchProperties(Map<String,String> params, Map<String,String> searchProperties, org.springframework.beans.BeanWrapperImpl searchWrapped, org.springframework.data.domain.ExampleMatcher matcher, boolean isExampleSearch)
      Leaves Markdown root and directory constraints to specification filtering.
      Overrides:
      getSearchProperties in class DatatableRestControllerV2<EmbeddingChunkEntity,Long>
      Parameters:
      params - request search parameters
      searchProperties - column properties populated by the base controller
      searchWrapped - wrapper for the example-search entity
      matcher - current example matcher
      isExampleSearch - whether example-based matching is active
      Returns:
      base matcher after excluding root and directory parameters
    • addSpecSearch

      public void addSpecSearch(Map<String,String> params, List<jakarta.persistence.criteria.Predicate> predicates, jakarta.persistence.criteria.Root<EmbeddingChunkEntity> root, jakarta.persistence.criteria.CriteriaBuilder builder)
      Adds document-group or shared Markdown path constraints before applying base search predicates.
      Overrides:
      addSpecSearch in class DatatableRestControllerV2<EmbeddingChunkEntity,Long>
      Parameters:
      params - request parameters defining source type and folder selection
      predicates - mutable collection receiving search predicates
      root - embedding chunk query root
      builder - criteria builder used to construct predicates
    • getMarkdownFolders

      @GetMapping("/markdown-folders") public List<String> getMarkdownFolders()
      Returns globally configured documentation roots for the shared Markdown tab.
      Returns:
      normalized configured documentation roots
    • getMarkdownFolderTree

      @PostMapping("/markdown-folders/tree") public Map<String,Object> getMarkdownFolderTree(@RequestBody Map<String,String> request)
      Supplies the shared folder picker with configured roots and lazily loaded child directories.
      Parameters:
      request - tree request containing a root marker or an encoded node ID in id
      Returns:
      success flag and child items, or a localized scan error
      Throws:
      org.springframework.web.server.ResponseStatusException - if the node ID or directory selection is invalid
    • getMarkdownStat

      @GetMapping("/markdown-stat") public Map<String,Object> getMarkdownStat(@RequestParam("folder") String folder, @RequestParam("action") String action, @RequestParam(value="directory",defaultValue="") String directory, @RequestParam(value="includeSubfolders",defaultValue="true") boolean includeSubfolders)
      Returns file, index, and queue counts for a selected Markdown directory scope.
      Parameters:
      folder - configured documentation root
      action - requested INDEX or DELETE action
      directory - root-relative directory, empty for the root
      includeSubfolders - whether to include descendant directories
      Returns:
      counts keyed by totalDocuments, indexedDocuments, and queuedDocuments
    • performMarkdownAction

      @PostMapping("/markdown-action") public int performMarkdownAction(@RequestParam("folder") String folder, @RequestParam("action") String action, @RequestParam(value="directory",defaultValue="") String directory, @RequestParam(value="includeSubfolders",defaultValue="true") boolean includeSubfolders)
      Enqueues indexing or deletion for the selected documentation scope for later processing.
      Parameters:
      folder - configured documentation root
      action - requested INDEX or DELETE action
      directory - root-relative directory, empty for the root
      includeSubfolders - whether to include descendant directories
      Returns:
      number of unique source files queued
    • getOptions

      public void getOptions(DatatablePageImpl<EmbeddingChunkEntity> page)
      Adds source types and languages appropriate to document or shared Markdown storage.
      Overrides:
      getOptions in class DatatableRestControllerV2<EmbeddingChunkEntity,Long>
      Parameters:
      page - datatable response receiving select options
    • processFromEntity

      public EmbeddingChunkEntity processFromEntity(EmbeddingChunkEntity entity, ProcessItemAction action)
      Adds pending or error row styling when chunks are returned for listing or searching.
      Overrides:
      processFromEntity in class DatatableRestControllerV2<EmbeddingChunkEntity,Long>
      Parameters:
      entity - chunk whose row styling may be updated
      action - datatable operation producing the chunk
      Returns:
      the supplied chunk with any applicable row class
    • getCurrentEmbeddingConfiguration

      @GetMapping("/current-embedding-configuration") public Map<String,String> getCurrentEmbeddingConfiguration(@RequestParam(value="entityType",defaultValue="DOCUMENT") String entityType)
      Returns the provider and model configured for RAG indexing in the current domain.
      Parameters:
      entityType - source type; both document and shared Markdown indexing use the current domain's assistant
      Returns:
      configuration map containing provider and model, or an empty map when no complete indexing assistant is configured
    • performDocumentAction

      @PostMapping("/document-action") public int performDocumentAction(@RequestParam("rootDir") int rootDir, @RequestParam("includeSubfolders") boolean includeSubfolders, @RequestParam("action") String action)
      Queues an indexing or deletion action for searchable documents in an authorized folder scope.
      Parameters:
      rootDir - root group ID, or -1 for all documents in the current domain
      includeSubfolders - whether documents in descendant groups should be included
      action - action to perform, expected to be INDEX or DELETE
      Returns:
      number of matched documents considered for queueing, 0 when none match, or -1 when queueing fails
      Throws:
      org.springframework.security.access.AccessDeniedException - if the requested group scope is invalid, not editable, or belongs to another domain
    • getDocumentStat

      @GetMapping("/document-stat") public Map<String,Object> getDocumentStat(@RequestParam("rootDir") int rootDir, @RequestParam("includeSubfolders") boolean includeSubfolders, @RequestParam("action") String action)
      Returns statistics about document indexing status for the specified folder. Returns total groups, total documents, already indexed count, and currently queued count.
      Parameters:
      rootDir - the root directory group ID (-1 for all domain documents)
      includeSubfolders - whether to include documents from subfolders
      action - the action to check queue status for
      Returns:
      map with keys: totalGroups, totalDocuments, indexedDocuments, queuedDocuments
      Throws:
      org.springframework.security.access.AccessDeniedException - if the requested group scope is invalid, not editable, or belongs to another domain