Interfaces


Below are the Interfaces used by the SearchStax Site Search solution’s various JS Widgets. As you use the JS library to write your custom search page, these provide you the details of the attributes used by each Interface.

Search Input Interfaces

export interface ISearchstaxSearchInputConfig {
  suggestAfterMinChars: number; // controls how many characters the UI should accept at the minimum before showing suggestions
  templates?: ISearchstaxSearchInputConfigTemplates; // optional object that defines template override options
  hooks?: { // optional object that provides various hook options
    beforeAutosuggest?: (props: ISearchstaxSuggestProps) => ISearchstaxSuggestProps | null; // this function gets called before firing autosuggest. autosuggestProps are being passed as a property and can be modified, if passed along further search will execute with modified properties, if null is returned then event gets canceled and search never fires.
    afterAutosuggest?: (result: ISearchstaxSuggestResponse) => ISearchstaxSuggestResponse; // this function gets called after autosuggest has values but before rendering. It needs to return same type of data but it can be modified.
  };
}

export interface ISearchstaxSearchProps {
  term: string;
  queryParams: string[];
}

export interface ISearchstaxSuggestProps {
  term: string;
  queryParams: IAdditionalProp[];
}

export interface ISearchstaxSearchInputConfigTemplates {
  mainTemplate?: ISearchstaxSearchInputMainTemplateData; // optional object for overriding main template
  autosuggestItemTemplate?: ISearchstaxSearchInputAutosuggestTemplateData; // autosuggest item template in Mustache
}

export interface ISearchstaxSearchInputMainTemplateData{
  template: string; // main template in Mustache templating language
  searchInputId: string; // id of search input within the mainTemplate
}

export interface ISearchstaxSearchInputAutosuggestTemplateData{
  template: string; // autosuggest template in Mustache templating language
}


Search Interfaces

export interface ISearchstaxSuggestResponseHeader {
  zkConnected: boolean;
  status: number;
  qTime: number;
}

export interface ISearchstaxSuggestion {
  term: string;
  weight: number;
  payload: string;
}

export interface ISearchstaxSEARCHTERM {
  numFound: number;
  suggestions: ISearchstaxSuggestion[];
}

export interface ISearchstaxStudio_suggestor_LANG {
  [key: string]: ISearchstaxSEARCHTERM;
}

export interface ISearchstaxSuggest {
  [key: string]: ISearchstaxStudio_suggestor_LANG;
}

export interface ISearchstaxSuggestResponse {
  responseHeader: ISearchstaxSuggestResponseHeader;
  suggest: ISearchstaxSuggest;
}


Search Results Interfaces

export interface ISearchstaxParam {
  q: string;
  language: string;
  echoParams: string;
  wt: string;
  rows: string;
  hl: string;
  "hl.snippets": string;
  facet: string;
  fl: string;
  "facet.field": string[];
  "f.content_type_facet.facet.limit": string;
  "f.content_type_facet.facet.mincount": string;
  "f.content_type_facet.facet.sort": string;
  "f.author_name.facet.limit": string;
  "f.author_name.facet.mincount": string;
  "f.author_name.facet.sort": string;
  "f.meta_keywords_facet.facet.limit": string;
  "f.meta_keywords_facet.facet.mincount": string;
  "f.meta_keywords_facet.facet.sort": string;
  defType: string;
  qf: string;
  uniqueId: string;
  "spellcheck.q": string;
  "spellcheck.accuracy": string;
  "spellcheck.extendedResults": string;
  spellcheck: string;
  "spellcheck.dictionary": string;
  "spellcheck.count": string;
  bq: string;
  bf: string;
  rid: string;
  autoCorrectedQ?: string;
}

export interface ISearchstaxResponseHeader {
  zkConnected: boolean;
  status: number;
  QTime: number;
  params: ISearchstaxParam;
}
export interface ISearchstaxDocCommon {
  [key: string]: string | string[] | boolean;
}

export interface ISearchstaxDoc extends ISearchstaxDocCommon {
  "[elevated]": boolean;
}

export interface ISearchstaxParsedResult {
  custom?: any;
  ribbon: string | null;
  paths: string | null;
  url: string | null;
  title: string | null;
  promoted: boolean | null;
  thumbnail: string | null;
  date: string | null;
  snippet: string | null;
  description: string | null;
  uniqueId: string;
  position: number;
  unmappedFields: { key: string; value: string | string[] | boolean; isImage?: boolean }[];
  allFields: { key: string; value: string | string[] | boolean }[];
}

export interface ISearchstaxSearchMetadata {
  recordsPerPageValue: number;
  startDocVal: number;
  totalResultsValue: number;
  latency: number;
  endDocValue: number;
  spellingSuggestion: string;
  autoCorrectedQuery: string;
  impressions: ISearchstaxImpression[];
}

export interface ISearchstaxImpression {
  cDocId: string;
  cDocTitle: string;
  position: number;
}
export interface ISearchstaxRelatedImpression {
  relatedSearch: string;
  position: number;
}

export interface ISearchstaxResponse {
  numFound: number;
  start: number;
  numFoundExact: boolean;
  docs: ISearchstaxDoc[];
}

export interface ISearchstaxFacet_query {}

export interface ISearchstaxFacet_field {
  content_type_facet: any[];
  author_name: any[];
  meta_keywords_facet: any[];
}

export interface ISearchstaxFacet_range {}

export interface ISearchstaxFacet_interval {}

export interface ISearchstaxFacet_heatmap {}

export interface ISearchstaxFacet_count {
  facet_queries: ISearchstaxFacet_query;
  facet_fields: ISearchstaxFacet_field;
  facet_ranges: ISearchstaxFacet_range;
  facet_intervals: ISearchstaxFacet_interval;
  facet_heatmaps: ISearchstaxFacet_heatmap;
}

export interface Spellcheck {
  suggestions: any[];
  correctlySpelled: boolean;
}

export interface ISearchstaxFacet {
  name: string;
  label: string;
}

export interface ISearchstaxResult {
  name: string;
  title: string;
  result_card: string;
}

export interface ISearchstaxSort {
  id: number;
  name: string;
  order: string;
  label: string;
}

export interface IExternalPromotion {
  name: string;
  id: number;
  url: string;
  description: string;
}

export interface ISearchstaxMetadata {
  facets: ISearchstaxFacet[];
  results: ISearchstaxResult[];
  sorts: ISearchstaxSort[];
}

export interface ISearchstaxSearchResponse {
  responseHeader: ISearchstaxResponseHeader;
  response: ISearchstaxResponse;
  facet_counts: ISearchstaxFacet_count;
  spellcheck: Spellcheck;
  metadata: ISearchstaxMetadata;
  externalLinks?: IExternalPromotion[];
}

export interface ISearchstaxParsedData {
  currentPage: number;
  totalResults: number;
  resultsPerPage: number;
  isFirstPage: boolean;
  results: ISearchstaxParsedResult[];
  isLastPage: boolean;
  hasResults: boolean;
  hasResultsOrExternalPromotions: boolean;
  searchExecuted: boolean;
  hasRelatedSearches: boolean;
  hasExternalPromotions: boolean;
  startResultIndex: number;
  endResultIndex: number;
  searchTerm: string;
  autoCorrectedQuery: string;
  originalQuery: string;
  selectedFacets: (IFacetValue | IFacetValueRange)[];
  relatedSearches: ISearchstaxRelatedSearchResult[];
  externalPromotions: IExternalPromotion[];
}

export interface ISearchstaxSearchResultsConfig {
  templates?: ISearchstaxSearchResultsConfigTemplates; // optional object that defines template override options
  hooks?: { // optional object that provides various hook options
    afterLinkClick?: (
      resultClicked: ISearchstaxParsedResult
    ) => ISearchstaxParsedResult | null; // function is called after user clicks result and passes that result as a property. when result is passed along tracking will execute and user will be navigated if null is returned events are canceled and nothing happens.
  };
}

export interface ISearchstaxSearchResultsConfigTemplates {
  mainTemplate?: ISearchstaxResultsMainTemplateData;
  searchResultTemplate?: ISearchstaxResultsResultTemplateData;
  noSearchResultTemplate?: ISearchstaxResultsNoResultTemplateData;
}

export interface ISearchstaxResultsMainTemplateData {
  template: string; // main template in Mustache templating language
  searchResultsContainerId: string; // this is needed only if mainTemplate is overridden. It points to an element in the template where results need to be rendered
}

export interface ISearchstaxResultsResultTemplateData {
  template: string; // result template using Mustache. ISearchstaxParsedResult is passed to the template and all its properties are available to be used when rendering;
  searchResultUniqueIdAttribute: string; // this is needed only if searchResultTemplate is overridden. searchResultTemplate needs to have unique result id property. Default is data-searchstax-unique-result-id="niqueId". see example below on how it is used
}
export interface ISearchstaxResultsNoResultTemplateData {
  template: string; // Mustache template for no results section override. spellingSuggestion and searchTerm are values available in the template
}

export interface ISearchstaxParsedResult {
  custom?: any;
  ribbon: string | null;
  paths: string | null;
  url: string | null;
  title: string | null;
  promoted: boolean | null;
  thumbnail: string | null;
  date: string | null;
  snippet: string | null;
  description: string | null;
  uniqueId: string;
  position: number;
  unmappedFields: { key: string; value: string | string[] | boolean; isImage?: boolean }[];
  allFields: { key: string; value: string | string[] | boolean }[];
}

Facets Interfaces

export interface IFacet {
  name: string;
  label: string;
  values: (IFacetValue | IFacetValueRange)[];
}

export interface IFacetValue {
  value: string;
  type: 'checkbox';
  parentName: string;
  count: number;
}

export interface IFacetValueRange {
  valueFrom: string;
  type: 'range';
  valueTo: string;
  parentName: string;
  count: number;
}

export interface IFacetData extends IFacet{
  values: (IFacetValue | IFacetValueRange)[];
  showingAllFacets?: boolean;
  hasMoreFacets?: boolean;
}

export interface IFacetsTemplateData extends ISearchstaxParsedData{
  facets: IFacetData[];
  isMobile?: boolean;
}

export interface IFacetValueData extends IFacetValue {
  disabled?: boolean;
}

export interface ISearchstaxSearchFacetsConfig {
  facetingType: "and" | "or" | "showUnavailable" | "tabs"; // type that determines how facets will behave
  specificFacets?: string[]; // optional array of facet names that if provided will only render those facets
  itemsPerPageDesktop: number; // default expanded facets for desktop
  itemsPerPageMobile: number; // default expanded facets for mobile
  templates?: ISearchstaxSearchFacetsClearFacetsTemplates; // optional object that defines template override options
}

export interface ISearchstaxSearchFacetsClearFacetsTemplates {
  mainTemplateDesktop?: ISearchstaxSearchFacetsMainTemplateData; // optional object for overriding main template
  mainTemplateMobile?: ISearchstaxSearchFacetsMainMobileTemplate; // optional object for overriding main mobile template
  showMoreButtonContainerTemplate?: ISearchstaxSearchFacetsShowMoreTemplateData; // optional object for overriding facet section show more/less template
  facetItemContainerTemplate?: ISearchstaxSearchFacetsItemContainerTemplateData; // optional object for overriding facet container template
  clearFacetsTemplate?: ISearchstaxSearchFacetsselectedFacetsTemplateData; // optional object for overriding clear facets container template
  facetItemTemplate?: ISearchstaxSearchFacetsItemTemplateData; // optional object for overriding clear facet item template
  filterByTemplate?: ISearchstaxSearchFacetsFilterByTemplateData; // optional object for overriding filter by button template
  selectedFacetsTemplate?: ISearchstaxSearchFacetsselectedFacetsTemplateData; // optional object for overriding selected facets template
}

export interface ISearchstaxSearchFacetsClearFacetsTemplateData {
  template: string;
  containerClass: string;
}

export interface ISearchstaxSearchFacetsselectedFacetsTemplateData {
  template: string; //main template in Mustache templating language. data available: IFacetValue | IFacetValueRange
  containerClass: string; //class where selected facets will be placed within the template
}

export interface ISearchstaxSearchFacetsFilterByTemplateData {
  template: string; //main template in Mustache templating language
  containerClass: string; // class where button will be placed within the template
}

export interface ISearchstaxSearchFacetsItemTemplateData {
  template: string; // main template in Mustache templating language. data available:  { ...IFacetValueData, isChecked }
  inputCheckboxClass?: string; // class of checkboxes
  checkTriggerClasses?: string[]; // class list of elements that trigger facet select/unselect action
}
export interface ISearchstaxSearchFacetsItemContainerTemplateData {
  template: string; // main template in Mustache templating language. data available: IFacetData
  facetListTitleContainerClass: string; // container class where facet category title will be rendered within template
  facetListContainerClass: string; // container class where facet items will be listed
}

export interface ISearchstaxSearchFacetsShowMoreTemplateData {
  template: string; // main template in Mustache templating language. data available: IFacetData
  showMoreButtonClass: string; // class of container where show more/less button will be placed
}
export interface ISearchstaxSearchFacetsMainTemplateData {
  template: string; // main template in Mustache templating language data available: IFacetsTemplateData
  facetsContainerClass: string;  // class of container where facets will be placed
  selectedFacetsContainerClass?: string; // class of container where selected facets will be placed
}

export interface ISearchstaxSearchFacetsMainMobileTemplate {
  template: string; // main template in Mustache templating language. data available: IFacetsTemplateData
  facetsContainerClass: string; // class of container where facets will be placed
  closeOverlayTriggerClasses?: string[]; // class list of all elements that should trigger mobile overlay close action
  filterByContainerClass?: string; // class of container where "Filter By" button will be rendered
  selectedFacetsContainerClass?: string; // class of container where selected facets will be listed
}

Pagination Interfaces

export interface IPaginationData extends ISearchstaxParsedData {
  nextPageLink: string;
  previousPageLink: string;
}

export interface ISearchstaxSearchPaginationConfig {
  templates?: ISearchstaxSearchPaginationConfigTemplates; // optional object that defines template override options
}

export interface ISearchstaxSearchPaginationConfigTemplates {
  mainTemplate?: ISearchstaxSearchPaginationTemplateData; // optional object for overriding main template
}

export interface ISearchstaxSearchPaginationTemplateData {
  template: string; // main template in Mustache templating language. Data available: IPaginationData
  previousButtonClass: string; // class of previous page link within template
  nextButtonClass: string; // class of next page link within template
}

Search Feedback Interfaces

export interface ISearchstaxSearchFeedbackConfig {
  templates?: ISearchstaxSearchFeedbackConfigTemplates; // optional object that defines template override options
}

export interface ISearchstaxSearchFeedbackConfigTemplates {
  main?: ISearchstaxSearchFeedbackTemplateData; // optional object for overriding main template
}

export interface ISearchstaxSearchFeedbackTemplateData {
  template: string; // main template in Mustache templating language,
  originalQueryClass: string; // class of element that contains original query and will execute search on click. Search term is innerHTML of that element
}

export interface ISearchstaxParam {
    q: string;
    fl: string;
    _forwardedCount: string;
    _: string;
  }

  export interface ISearchstaxRelatedSearchesResponseHeader {
    zkConnected: boolean;
    status: number;
    qTime: number;
    params: ISearchstaxParam;
  }

  export interface ISearchstaxRelatedSearchResult {
    search_term: string;
    related_search: string;
    score: number;
    last?: boolean;
    position?: number;
  }

  export interface ISearchstaxRelatedSearchesResponseBody {
    numFound: number;
    start: number;
    maxScore: number;
    numFoundExact: boolean;
    docs: ISearchstaxRelatedSearchResult[];
  }

  export interface ISearchstaxRelatedSearchesResponse {
    responseHeader: ISearchstaxRelatedSearchesResponseHeader;
    response: ISearchstaxRelatedSearchesResponseBody;
  }

export interface ISearchstaxRelatedSearchesConfig {
  relatedSearchesURL: string; // URL of related searches endpoint
  relatedSearchesAPIKey: string; // related searches api key
  templates?: ISearchstaxRelatedSearchesConfigTemplates; // optional object that defines template override options
}

export interface ISearchstaxRelatedSearchesConfigTemplates {
  main?: ISearchstaxRelatedSearchesTemplateData; // optional object for overriding main template
  relatedSearch?: ISearchstaxRelatedSearchTemplateData; // optional object for overriding related search template
}

export interface ISearchstaxRelatedSearchesTemplateData {
  template: string; // main template in Mustache templating language
  relatedSearchesContainerClass: string; // class where related searches will be rendered within the template
}
export interface ISearchstaxRelatedSearchTemplateData {
  template: string; // main template in Mustache templating language
  relatedSearchContainerClass: string; //  class where related search item will be rendered within the template
}

Promotions Interfaces

export interface IExternalPromotion {
  name: string;
  id: number;
  url: string;
  description: string;
}

export interface ISearchstaxExternalPromotionsConfig {
  templates?: ISearchstaxExternalPromotionsTemplates // optional object that defines template override options
}

export interface ISearchstaxExternalPromotionsTemplates{
  mainTemplate?: ISearchstaxExternalPromotionsTemplateData; // optional object for overriding main template
  externalPromotion?: ISearchstaxExternalPromotionTemplateData; // optional object for overriding main template
}

export interface ISearchstaxExternalPromotionsTemplateData {
  template: string; // main template in Mustache templating language
  externalPromotionsContainerId: string; // id where external promotions will be rendered within the template
}

export interface ISearchstaxExternalPromotionTemplateData {
  template: string; // main template in Mustache templating language
}

Sorting Interfaces

export interface ISearchstaxSearchSortingData  extends ISearchstaxParsedData{

}

Questions?

Do not hesitate to contact the SearchStax Support Desk.