Is there a way to ignore any fields that don't exist on the Index or don't have a field mapping on the Indexer? Or a way to specify on the Indexer or on Import to ignore a specific field?
I am creating a Azure Search Index where the data source is CosmosDB. Because CosmosDB has a flexible schema I may periodically add new fields. I would prefer these not be indexed and it remain the original schema. Is there a way to set on either the Index or Indexer to ignore new fields (or even this specific field) when add new items to the Index?
I didn't see anything to ignore fields in the field mapping docs: https://learn.microsoft.com/en-us/azure/search/search-indexer-field-mappings
The solution depends on which model you use.
See https://docs.microsoft.com/en-us/azure/search/cognitive-search-output-field-mapping
So, the solution is not to ignore anything. You rather explicitly map the bits you want.
FWIW: I've got a similar problem. I had already both models, the CosmosDB model and the AzureSearch model. The thing is that I need to add a flag on the latter, so in case it is not flagged perform a Delete operation on the index, or an update otherwise. (In my case, passing the flag from one model to another was the cheapest way otherwise I'd have needed a big refactor).
Since I didn't need the flag (to be persisted) on the SeachModel, using JsonIgnore attribute worked for me. If you need the value, the FieldBuilderIgnore attribute may help, see https://learn.microsoft.com/en-us/do.net/api/azure.search.documents.indexes.fieldbuilderignoreattribute?view=azure-do.net .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.