THIS IS ARCHIVED DOCUMENTATION

(Deprecated) RelevanceInspector

The RelevanceInspector controller is in charge of allowing displaying various debug information.

Methods

disable

Disables debug mode.

enable

Enables debug mode.

logInformation

Logs debug information to the console.

subscribe

Adds a callback that will be called on state change.

Parameters

  • listener: () ⇒ void

    A callback to be invoked on state change.

Returns Unsubscribe: An unsubscribe function to remove the listener.

Attributes

state

The state of the RelevanceInspector controller.

Properties

Initialize

buildRelevanceInspector

Creates a RelevanceInspector controller instance.

Parameters

  • engine: Engine<DebugSection & SearchSection & ConfigurationSection>

    The headless engine.

  • props: RelevanceInspectorProps

    The configurable RelevanceInspector properties.

Returns RelevanceInspector

RelevanceInspectorProps

The configurable RelevanceInspector properties.

Properties

RelevanceInspectorInitialState

The initial state that should be applied to the RelevanceInspector controller.

Properties

  • enabled?: boolean

    Whether debug mode should be enabled.

RelevanceInspectorOptions

The options for the RelevanceInspector controller.

Properties

  • automaticallyLogInformation?: boolean

    Whether to automatically log state to console on new responses.

ExecutionReport

Properties

  • children: ExecutionStep[]

    The steps involved in processing the query.

  • duration: number

    The total time, in milliseconds, needed to process the query.

ExecutionStep

Properties

  • [key: string]: unknown

    Custom keys for the step, holding additional debugging information.

  • description: string

    The step description.

  • duration: number

    The time, in milliseconds, spent on the step.

  • name: string

    The step name.

  • children?: ExecutionStep[]

    The sub-steps making up the step.

  • result?: Record<string, unknown>

    The values returned by the step.

HighlightKeyword

Properties

  • length: number

    The length of the offset.

  • offset: number

    The 0 based offset inside the string where the highlight should start.

QueryExpressions

Properties

  • advancedExpression: string

    The dynamic filter expression, sent as the aq parameter in the request.

  • basicExpression: string

    The search query.

  • constantExpression: string

    The static filter expression, typically set by a Tab.

QueryRankingExpression

Properties

  • expression: string

    The query ranking expression (QRE).

  • modifier: string

    The change to the ranking score applied by the query ranking expression (QRE).

Raw

Properties

  • [key: string]: unknown

    Custom keys that depend on the documents in the index.

Result

Properties

  • absentTerms: string[]

    The basic query expression terms which this query result item does not match. Note: This property is populated by terms from the query pipeline-processed q value (not from the original q value).

  • clickUri: string

    The hyperlinkable item URI. Notes: Use the clickUri value when you want to create hyperlinks to the item, rather than the uri or printableUri value.

  • excerpt: string

    The contextual excerpt generated for the item (see the excerptLength query parameter).

  • excerptHighlights: HighlightKeyword[]

    The length and offset of each word to highlight in the item excerpt string.

  • firstSentences: string

    The first sentences retrieved from the item (see the retrieveFirstSentences query parameter).

  • firstSentencesHighlights: HighlightKeyword[]

    The length and offset of each word to highlight in the item firstSentences string.

  • flags: string

    The flags that are set on the item by the index. Distinct values are separated by semicolons.

  • hasHtmlVersion: boolean

    Whether the index contains an HTML version of this item.

  • isRecommendation: boolean

    Whether the item score was boosted as a Coveo ML recommendation.

  • isTopResult: boolean

    Whether the item score was boosted by a featured result rule in the query pipeline.

  • percentScore: number

    The item ranking score expressed as a percentage (see the sortCriteria and rankingFunctions query parameters).

  • printableUri: string

    The human readable item URI. Note: Avoid using the printableUri value to create hyperlinks to the item. Use the clickUri value instead.

  • printableUriHighlights: HighlightKeyword[]

    The length and offset of each word to highlight in the item printableUri string.

  • rankingInfo: string | null

    The raw debug information generated by the index to detail how the item was ranked. This property is null unless the debug query parameter is set to true.

  • raw: Raw

    The values of the fields which were retrieved for this item (see the fieldsToInclude and fieldsToExclude query parameters).

  • score: number

    The total ranking score computed for the item (see the sortCriteria and rankingFunctions query parameters).

  • summary: null

    The item summary (see the summaryLength query parameter).

  • summaryHighlights: HighlightKeyword[]

    The length and offset of each word to highlight in the item summary string.

  • title: string

    Contains the title of the item.

  • titleHighlights: HighlightKeyword[]

    The length and offset of each word to highlight in the item title string.

  • uniqueId: string

    The unique item identifier. You should consider the uniqueId value as an opaque string.

  • uri: string

    The item URI. Notes: Avoid using the uri value to create hyperlinks to the item. Use the clickUri value instead.

  • rankingModifier?: string

    If applicable, represents the type of ranking modification that was applied to this result.

ResultRankingInformation

Properties

  • ranking: RankingInformation | null

    The ranking information for the associated result.

  • result: Result

    The result.

SecurityIdentity

Properties

  • name: string

    The security identity name.

  • provider: string

    The security identity provider.

  • type: string

    The security identity type. Possible values are USER, GROUP, VIRTUAL_GROUP, or UNKNOWN.

Unsubscribe

Call signatures

  • (): void

Example Implementation

relevance-inspector.fn.tsx

import {useEffect, useState, FunctionComponent} from 'react';
import {RelevanceInspector as HeadlessRelevanceInspector} from '@coveo/headless';
 
interface RelevanceInspectorProps {
  controller: HeadlessRelevanceInspector;
}
 
export const RelevanceInspector: FunctionComponent<RelevanceInspectorProps> = (
  props
) => {
  const {controller} = props;
  const [state, setState] = useState(controller.state);
 
  useEffect(
    () =>
      controller.subscribe(() => {
        console.info('Debug information [fn]', controller.state);
        setState(controller.state);
      }),
    []
  );
 
  return (
    <div>
      <label>
        Enable debug mode:{' '}
        <input
          type="checkbox"
          checked={state.isEnabled}
          onChange={() =>
            state.isEnabled ? controller.disable() : controller.enable()
          }
        />
      </label>
    </div>
  );
};
 
// usage
 
/**
 * ```tsx
 * const controller = buildRelevanceInspector(engine);
 *
 * <RelevanceInspector controller={controller} />;
 * ```
 */