Reputation: 4298
I have a Azure Cognitive Search set up with two DataSources, two Indexers indexing those DataSources and one Index.
I'd like to be able to able to query/filter by DataSource. Is that possible?
Upvotes: 0
Views: 712
Reputation: 4298
Off of @Derek Legenzoff serve this is how I did it...
Add all your datasources
Create skillsets
for each one data source with the following skill
{
"@odata.type": "#Microsoft.Skills.Util.ConditionalSkill",
"name": "#1",
"description": "",
"context": "/document",
"inputs": [
{
"name": "condition",
"source": "= true"
},
{
"name": "whenTrue",
"source": "= 'Production'" //name of your environment
},
{
"name": "whenFalse",
"source": "= ''"
}
],
"outputs": [
{
"name": "output",
"targetName": "Env"
}
]
}
Create single index
for your data model and add a Env
field, and it's filterable and queryable
Create indexers
for each one of your data sources that point to the index
from step 3 and datasource
from step 1
IMPORTANT: make sure you indexers have the following code in the definition.
"outputFieldMappings": [
{
"sourceFieldName": "/document/Env",
"targetFieldName": "Env"
}
],
This will connect the product of the skill
to the index
Upvotes: 0
Reputation: 136
This is certainly possible. You'd just need to find a way to get a field in the index that contains the name of the data source. The best way to do this depends on the data source you're using--for example, if you're using a SQL data source, you might just be able to edit the query to return the value whereas that wouldn't work for blob storage.
Another option that would work for all data sources would be to include a skillset with a conditional skill which you can use to set a default value for a field.
Upvotes: 0