All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.adobe.granite.omnisearch.api.core.OmniSearchService Maven / Gradle / Ivy

There is a newer version: 6.5.21
Show newest version
/*************************************************************************
 *
 * ADOBE CONFIDENTIAL
 * __________________
 *
 *  Copyright 2015 Adobe Systems Incorporated
 *  All Rights Reserved.
 *
 * NOTICE:  All information contained herein is, and remains
 * the property of Adobe Systems Incorporated and its suppliers,
 * if any.  The intellectual and technical concepts contained
 * herein are proprietary to Adobe Systems Incorporated and its
 * suppliers and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Adobe Systems Incorporated.
 **************************************************************************/

package com.adobe.granite.omnisearch.api.core;

import org.osgi.annotation.versioning.ProviderType;
import com.adobe.granite.omnisearch.api.suggestion.SuggestionResult;
import com.day.cq.search.result.SearchResult;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import com.day.cq.i18n.I18n;

import java.util.Iterator;
import java.util.Map;

/**
 * OmniSearch enables different search modules (or location) to plugin with common and unified search interface i.e. OmniSearch.
 * A search module generally handles search related to a one or more resource type i.e. Asset, Site, User, Group, Asset Collection
 * etc.
 *
 * OmniSearch enables couple of key functionalities
 * 
    *
  • Suggestions & SpellCheck
  • *
  • Predicate Suggestions
  • *
  • Common Search - search across all modules
  • *
  • Search within a particular module i.e. Asset
  • *
  • Saved Search functionality for the module that implements SavedSearchHandler
  • *
* Each module has the flexibility to handle/specify query by registering a OmniSearchHandler */ @ProviderType public interface OmniSearchService { /** * Location has 1:1 mapping with a search module. location in * search request parameter, can specify particular search module to search. * i.e. if location = "x", then omnisearch would only search module that has ID = "x" * @see com.adobe.granite.omnisearch.spi.core.OmniSearchHandler#getID() */ public static final String LOCATION = "location"; static final String MIN_LENGTH_SUGGESTION_PROPERTY = "omnisearch.suggestion.requiretext.min"; static final String SPELLCHECK_REQUIRE_PROPERTY = "omnisearch.suggestion.spellcheck.require"; static final int MIN_LENGTH_FOR_SUGGESTION = 3; static final boolean SPELLCHECK_REQUIRE = false; /** * * This function returns the search result for OmniSearch. * * Depending on predicateParamters, it could contain results from multiple * search modules or one of the search module. * * If user does not have access to any module, that module will * not be present in search Results. * @param resolver ResourceResolver instance * @param predicateParameters Map of parameters this should be in format of <String, String> or <String, String[]> * @param limit number of result on a page * @param offset pffset for next page result @return * @return Return Results in format Map with Key as location @see com.adobe.granite.omnisearch.api.core.OmniSearchService#LOCATION , * and Value as SearchResult. */ public Map getSearchResults(ResourceResolver resolver, Map predicateParameters, long limit, long offset); /**This function will return suggestions for omnisearch. * Suggestion Result will be in format of Map with key as String * and Value as SuggestionResult * If user does not have access to any module, that module will * not be present in search Results. * @param resolver ResourceResolver instance * @param i18n I18n instance * @param term text term for which suggestions are require * @param location this is unique id for each module @see com.adobe.granite.omnisearch.api.core.OmniSearchService#LOCATION. * @return Map */ public Map getSuggestions(ResourceResolver resolver, I18n i18n, String term, String location); /** * This function will return all search modules and their configuration * that are registered with OmniSearch. * @param resolver ResourceResolver instance * @return a map with key as location and value as configuration resource * @see com.adobe.granite.omnisearch.spi.core.OmniSearchHandler#getModuleConfig(org.apache.sling.api.resource.ResourceResolver) */ public Map getModules(ResourceResolver resolver); /** * This function will return the configuration Resource of the * search modules that is registered with OmniSearch. * @param resolver ResourceResolver instance * @param location this is unique id for each module @see com.adobe.granite.omnisearch.api.core.OmniSearchService#LOCATION. * @return resource */ public Resource getModuleConfiguration(ResourceResolver resolver, String location); /**This function returns the list of saved searches for the particular module that is register with * omnisearch and has SavedSearchHandler implemented * @param resolver ResourceResolver instance * @param location this is unique id for each module @see com.adobe.granite.omnisearch.api.core.OmniSearchService#LOCATION. * @param limit number of result on a page * @param offset offset for next page result * @return Iterator of Resource of nodes of saved search for the module. * @throws OmniSearchException instance of OmniSearchException which provide error from the module */ public Iterator getSavedSearches(ResourceResolver resolver, String location, long limit, long offset) throws OmniSearchException; /** This function returns the details of saved Query parameters for the particular saved search. * * @param resolver ResourceResolver instance * @param location this is unique id for each module @see com.adobe.granite.omnisearch.api.core.OmniSearchService#LOCATION * @param path path of the node of saved search, from which parameters of saved search Query required * @return Map containing parameters of the Query * @throws OmniSearchException instance of OmniSearchException which provide error from the module */ public Map getSavedSearchParameters(ResourceResolver resolver, String location, String path) throws OmniSearchException; /** This function creates a new saved search or updates a existing saved search based on the * parameters provided in predicateMap parameter. * * @param resolver ResourceResolver instance * @param requestParameters Map of the parameters in format <String, String> or <String, String[]> * containing all parameters that needed to be saved as Query parameter * @return ResourceResolver instance * @throws OmniSearchException instance of OmniSearchException which provide error from the module */ public Resource createOrUpdateSavedSearch(ResourceResolver resolver, Map requestParameters) throws OmniSearchException; /** * This function delete the saved search node existing on the provided path * @param resolver ResourceResolver instance * @param location this is unique id for each module @see com.adobe.granite.omnisearch.api.core.OmniSearchService#LOCATION * @param path path of the node of saved search to delete * @return true, if node deleted successfully, false otherwise. * @throws OmniSearchException instance of OmniSearchException which provide error from the module */ public boolean deleteSavedSearch(ResourceResolver resolver, String location, String path) throws OmniSearchException; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy