Indexing Pipeline Extension Condition Syntax Reference
Indexing Pipeline Extension Condition Syntax Reference
You can optionally add conditions on your extensions to control on which items they must be executed. The condition is part of the extension configuration when you apply the extension to a source, not in the extension Python script itself. This way, the Coveo indexing pipeline loads and executes the extension only for items for which the condition evaluates to True, allowing to optimize crawling performances.
You can apply an extension to a given source and specify a condition from the Coveo Administration Console (see Apply an Extension to a Source). Alternatively, you can also apply an extension to a given source and specify a condition using the Coveo API (see Apply an Extension to a Source).
See the information below for extension condition syntax and examples.
Syntax
Indexing pipeline extension conditions are essentially built with metadata, metadata values, and operators.
-
Metadata syntax:
%[metadataName]
-
Supported operators:
==
,NOT
,AND
,OR
,()
Notes
|
Condition Syntax Examples
The following table presents examples of the different condition syntax features that can help you apply useful indexing pipeline extensions to sources (see Apply an Extension to a Source).
Condition syntax example | Evaluate to true if | ||
---|---|---|---|
|
The metadata |
||
|
The metadata |
||
|
The value of |
||
|
The metadata |
||
|
The metadata |
||
|
Both metadata exist on the item. |
||
|
Both metadata values equal |
||
|
At least one of the metadata exists on the item. |
||
|
At least one of the metadata value equals |
||
|
At least one of the metadata joined by The metadata
|
||
|
The metadata |
Pitfalls to Avoid
-
You can’t directly compare one metadata to another (for example,
%[meta1] == %[meta2]
).Rather use:
%[meta1] == 'value' AND %[meta2] == 'value'
-
You can’t use operators between values (for example,
%[fruit] == 'apple' OR 'orange'
isn’t valid).Rather use:
%[fruit] == 'apple' OR %[fruit] == 'orange'
-
You can’t use the inequality operator
!=
.Rather use
NOT %[meta1] == 'value'
. -
Conditions don’t support specifying an origin (
crawler
,converter
,mapping
). The comparisons are always done using the latest value for the metadata so you must be aware of the indexing pipeline stage at which your extension is executed.