RelevanceInspector
RelevanceInspector
|
|
Note
This component was introduced in version |
Example implementation
relevance-inspector.fn.tsx
import {RelevanceInspector as HeadlessRelevanceInspector} from '@coveo/headless';
import {useEffect, useState, FunctionComponent} from 'react';
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>
<label>
Enable fetch all fields:{' '}
<input
type="checkbox"
checked={state.fetchAllFields}
onChange={() =>
state.fetchAllFields
? controller.disableFetchAllFields()
: controller.enableFetchAllFields()
}
/>
</label>
<button onClick={() => controller.fetchFieldsDescription()}>
{' '}
Retrieve fields description
</button>
</div>
);
};
// usage
/**
* ```tsx
* const controller = buildRelevanceInspector(engine);
*
* <RelevanceInspector controller={controller} />;
* ```
*/
The RelevanceInspector controller is in charge of allowing displaying various debug information.
Methods
disable
Disables debug mode.
disableFetchAllFields
Disable fetching all available fields from the index.
enable
Enables debug mode.
enableFetchAllFields
Fetch all fields available from the index on each individual results.
fetchFieldsDescription
Fetch the description of all fields available from the index.
subscribe
Adds a callback that’s invoked on state change.
Parameters
-
listener:
() => voidA callback that’s invoked on state change.
Returns Unsubscribe: A function to remove the listener.
Attributes
state
The state of the RelevanceInspector controller.
Properties
-
isEnabled:
booleanWhether debug mode is enabled.
-
executionReport?:
ExecutionReportThe query execution report.
-
expressions?:
QueryExpressionsThe query expressions sent in the request.
-
fetchAllFields?:
booleanWhether fields debugging is enabled, returning all fields available on query results.
-
fieldsDescription?:
FieldDescription[]The description of all fields available in the index.
-
rankingExpressions?:
QueryRankingExpression[]The ranking expressions.
-
rankingInformation?:
ResultRankingInformation[]The ranking information for every result.
-
userIdentities?:
SecurityIdentity[]The security identities.
Initialize
buildRelevanceInspector
Creates a RelevanceInspector controller instance.
Parameters
-
engine:
SearchEngineThe headless engine.
-
props:
RelevanceInspectorPropsThe configurable
RelevanceInspectorproperties.
Returns RelevanceInspector
RelevanceInspectorProps
The configurable RelevanceInspector properties.
Properties
-
initialState?:
RelevanceInspectorInitialStateThe initial state that should be applied to the
RelevanceInspectorcontroller.
RelevanceInspectorInitialState
The initial state that should be applied to the RelevanceInspector controller.
Properties
-
enabled?:
booleanWhether debug mode should be enabled.
Related types
ExecutionReport
Properties
-
children:
ExecutionStep[]The steps involved in processing the query.
-
duration:
numberThe total time, in milliseconds, needed to process the query.
ExecutionStep
Properties
-
[key: string]:
unknownCustom keys for the step, holding additional debugging information.
-
description:
stringThe step description.
-
duration:
numberThe time, in milliseconds, spent on the step.
-
name:
stringThe step name.
-
children?:
ExecutionStep[]The sub-steps making up the step.
-
result?:
Record<string, unknown>The values returned by the step.
FieldDescription
Properties
-
defaultValue:
stringThe default value of the field.
-
description:
stringA modest description of the field.
-
fieldSourceType:
stringThe
fieldSourceType. -
fieldType:
stringThe
fieldType(eg., Date, Double, Integer, LargeString, Long, SmallString). -
groupByField:
booleanWhether the field is considered
groupBy(facet). -
includeInQuery:
booleanWhether the field can be referenced in a query.
-
includeInResults:
booleanWhether the field is returned with results.
-
name:
stringThe field name.
-
sortByField:
booleanWhether the field can be used to sort results.
-
splitGroupByField:
booleanWhether the field is considered
splitGroupBy(that is, facet with values delimited by;). -
type:
stringThe field type.
HighlightKeyword
Properties
-
length:
numberThe length of the offset.
-
offset:
numberThe 0 based offset inside the string where the highlight should start.
QueryExpressions
Properties
-
advancedExpression:
stringThe dynamic filter expression, sent as the
aqparameter in the request. -
basicExpression:
stringThe search query.
-
constantExpression:
stringThe static filter expression, typically set by a
Tab.
QueryRankingExpression
Properties
-
expression:
stringThe query ranking expression (QRE).
-
modifier:
stringThe change to the ranking score applied by the query ranking expression (QRE).
Raw
Properties
-
[key: string]:
unknownCustom 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:
stringThe 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:
stringThe 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:
stringThe 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:
stringThe flags that are set on the item by the index. Distinct values are separated by semicolons.
-
hasHtmlVersion:
booleanWhether the index contains an HTML version of this item.
-
isRecommendation:
booleanWhether the item score was boosted as a Coveo ML recommendation.
-
isTopResult:
booleanWhether the item score was boosted by a featured result rule in the query pipeline.
-
isUserActionView:
booleanWhether the result item has been previously viewed by one of the users specified in the
canSeeUserProfileOfsection of the search token generated to perform the search request. -
percentScore:
numberThe item ranking score expressed as a percentage (see the sortCriteria and rankingFunctions query parameters).
-
printableUri:
stringThe 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 | nullThe 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:
RawThe values of the fields which were retrieved for this item (see the fieldsToInclude and fieldsToExclude query parameters).
-
score:
numberThe total ranking score computed for the item (see the sortCriteria and rankingFunctions query parameters).
-
searchUid:
stringThe unique identifier of the search that returned this result.
-
summary:
nullThe item summary (see the summaryLength query parameter).
-
summaryHighlights:
HighlightKeyword[]The length and offset of each word to highlight in the item summary string.
-
title:
stringContains the title of the item.
-
titleHighlights:
HighlightKeyword[]The length and offset of each word to highlight in the item title string.
-
uniqueId:
stringThe unique item identifier. You should consider the uniqueId value as an opaque string.
-
uri:
stringThe item URI. Notes: Avoid using the uri value to create hyperlinks to the item. Use the clickUri value instead.
-
rankingModifier?:
stringIf applicable, represents the type of ranking modification that was applied to this result.
ResultRankingInformation
Properties
-
ranking:
RankingInformation | nullThe ranking information for the associated result.
-
result:
ResultThe result.
SecurityIdentity
Properties
-
name:
stringThe security identity name.
-
provider:
stringThe security identity provider.
-
type:
stringThe security identity type. Possible values are
USER,GROUP,VIRTUAL_GROUP, orUNKNOWN.
Unsubscribe
Call signatures
-
(): void;