Class SearchMatchService

java.lang.Object
io.meeds.social.search.service.SearchMatchService

@Service public class SearchMatchService extends Object
Collects the answers of the SearchMatchPlugin contributors of one unified-search content type and merges them, once, for every host: a host calls collect(String, SearchMatchRequest, List) and writes the ids it returns into its own query, beside its permission filters; it keeps no merge logic of its own.
Since:
8.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The grammar a contributed id must match to reach a host's query: letters, digits and dashes, 64 characters at most.
    static final int
    The number of contributed ids a search keeps, all contributors merged.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    io.meeds.social.search.model.SearchMatches
    collect(String contentType, io.meeds.social.search.model.SearchMatchRequest request, List<io.meeds.social.search.plugin.SearchMatchPlugin> legacyContributors)
    Asks every contributor of a content type once for the objects matching a keyword, and merges their answers.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • CONTRIBUTED_ID_PATTERN

      public static final String CONTRIBUTED_ID_PATTERN
      The grammar a contributed id must match to reach a host's query: letters, digits and dashes, 64 characters at most. Any other id is dropped.
      See Also:
    • MAX_CONTRIBUTED

      public static final int MAX_CONTRIBUTED
      The number of contributed ids a search keeps, all contributors merged.
      See Also:
  • Constructor Details

    • SearchMatchService

      public SearchMatchService()
  • Method Details

    • collect

      public io.meeds.social.search.model.SearchMatches collect(String contentType, io.meeds.social.search.model.SearchMatchRequest request, List<io.meeds.social.search.plugin.SearchMatchPlugin> legacyContributors)
      Asks every contributor of a content type once for the objects matching a keyword, and merges their answers.

      The contributors are looked up by type at each call, kept when their SearchMatchPlugin.getContentType() is the given content type, and called in the order of their implementation's fully qualified class name, whatever the order the container registered them in (the Kernel-Spring bridge keeps no Spring bean name in the container, it registers each bean under its class); the given legacy contributors are called next, in the order given. Each object id is kept once, at most 1000 in all, with the match line of the first contributor that gave it, or none when that contributor gave none (as the task and file searches merged their contributors); an id outside "[A-Za-z0-9-]{1,64}" is dropped. A contributor that throws is logged and skipped.

      Parameters:
      contentType - the host's unified-search content type
      request - what the contributors are asked
      legacyContributors - the host's deprecated contributors, each wrapped as a SearchMatchPlugin, or an empty list
      Returns:
      the merged answer, SearchMatches.EMPTY when no contributor found anything, never null