How to filter your search on sources.
Note: this feature only works with for calls to the /search
endpoint with parameter outputType='sourcedAnswer'
How Filtering works
Our /search
endpoint allows for restricting its search scope. It supports the following:
- Restrictions: restrict the search to a set list of sources
- Exclusions: exclude a set list of sources from the search
- Prioritization: create a prioritized list of sources to search on. The information will be looked for on the sources by order of priority
To filter, we use an XML format that must be appended to the natural language query passed to the /search
endpoint.
For example:
<guidance>
<restriction>Use only the sources listed here. Do not rely on any external references.
- wikipedia.org
</restriction>
</guidance>
Restrictions
Restrictions can be used to force the /search
endpoint to return from a set list of sources only. It should use the format of the example below:
<guidance>
<restriction>Use only the sources listed here. Do not rely on any external references.
- wikipedia.org
</restriction>
</guidance>
Exclusions
Exclusions can be used to block the /search
endpoint from returning information from a list of sources. It should be used in the format of the example below:
<guidance>
<exclusion>Do not use any of the sources listed here.
- buzzfeed.com
</exclusion>
</guidance>
Prioritization
Prioritizations can be used to favor some sources. The /search
endpoint will try to find the requested information in the favored sources. If unsuccessful, it will fall back to other sources. Prioritization can be used in tiers.
<guidance>
<priority>
- wikipedia.org
</priority>
</guidance>
<guidance>
<priority level='1'>
- wikipedia.org
</priority>
<priority level='2'>
- buzzfeed.com
</priority>
</guidance>
Examples
The different restrictions can be used together.
Exclusion + Prioritization
<guidance>
<exclusion>Do not use any of the sources listed here.
- buzzfeed.com
</exclusion>
<priority level='1'>
- wikipedia.org
</priority>
<priority level='2'>
- sec.gov
</priority>
</guidance>
Restriction + Prioritization
<guidance>
<restriction>Use only the sources listed here. Do not rely on any external references.
- wikipedia.org
- sec.gov
</restriction>
<priority>
- wikipedia.org
</priority>
</guidance>