So I ran further tests:
Setting contentType: no success -> title is indexed, but not textContent
attributeSet.contentType = UTType.plainText.identifier
attributeSet.textContent = ocrText
I tried printing the entity textContent just before indexing:
NSLog("Indexing entity with OCR = \(entity.attributeSet.textContent ?? "")")
try await CSSearchableIndex.default().indexAppEntities([entity])
It correctly prints out the textContent of the entity.
--> Core Spotlight indexes the entity, but seems to ignore the textContent field
Modified the AppIntentsJournal project from Apple, to fill in the textContent field in the indexed attribute set.
--> textContent is correctly indexed in that project
The entity are almost identically the same in both projects.
What could cause a difference in behavior from CoreSpotlight?
Topic:
App & System Services
SubTopic:
Automation & Scripting
Tags: