multiple persistent stores, can I have one for each entity?

for years, I have avoided CD for this particular project.

but I need spotlight support, and There seems to be only 1 way to get it these days: use core data. It wasn't always this way, and in my first release, I was able to find multiple 3rd party walkthroughs for getting spotlight support up and running. Those tutorials no longer work, and some of them no longer have any context.


so my application is NOT a good fit for CD, but I am trying to determine if I can make it work, because spotlight is a requirement, and there seems to be no other path to spotlight.


My first hurdle is persistent stores, can I have 1 persistent store Per entity?

I know that this is a strange question. I don't want to ask it, I would rather just build the spotlight plugin myself. This however, is not an option. Apparently guessing how to do something, doesn't just make it work.

I need to save files, and those individual files need to have spotlight metadata in them, such that when the user does a spotlight search, he finds the individual file and not the database of entities, which offers zero context.

IF CD allows you to save each individual entity by itself, I'm golden. But the docs aren't exactly helpful in this regard.

It seems that I can easily tell CD to store TYPES of entities separately. But we're not talking about doing that.


anticipating gotachas:

No, there are no relationships between entities at all. the entity is literally just a list of short strings. that will become metadata.



thoughts + guidance is appreciated.

When you set up a CoreData runtime environment, you can configure it so that it uses multiple persistent stores and could go as far as having one entity type per store. Doing so would cause some difficulties if you wanted any relationships between the entities.


If you're talking about "One and only one entity per persistent store", that's essentially "I want to create a bunch of different databases, each with one table with one row in them." And, that's why you don't see anyone explaining how to do it.


Do you understand how to create a persistent store and how to create an entity in that persistent store?


On the other hand, should you be asking about how to use CoreSpotlight instead?

https://developer.apple.com/library/ios/documentation/General/Conceptual/AppSearch/AppContent.html

or about Spotlight on the Mac?

https://developer.apple.com/library/prerelease/mac/documentation/Carbon/Conceptual/MetadataIntro/MetadataIntro.html#//apple_ref/doc/uid/TP40001280-BBCFBCAG


For the record, I vaguely remember the Spotlight support talks mentioning CoreData as an easy way of supporting spotlight searches, but as far as I can tell, that's not what the documentation says to do. But according to the documentation, Spotlight support has nothing to do with Core Data.

I know, it's rediculous.


this is spotlight ON Mac os X. and if you looked at the documentation you have linked, you'd notice that the last time it was updated was 2013. Since that point, Spotlight has been seriously affected by the sandbox, and has undergone numerous, undocumented changes, that render the docs completely out of date. I know, because I've been trying to work with them for 6 months.


3rd parties don't know how to make spotlight plugins anymore, and Apple isn't documenting it. I've asked.


so, making a persistent store is next for me.

thnx,

-td

Then the first step you need to do is:


Prove that Spotlight is going to search through multiple persistent stores scattered through your application package, if it's ignoring the spotlight meta-data.

who said anything about it searching through persistent stores scattered through my application package? I certainly didn't suggest that.

the stores will have individual file paths. Similar to, but not precisely the same as a document based app.

So what makes you think that Spotlight will search each of the individual persistent stores, anyway?


The Core Data Spotlight Integration documentation is just as old as the rest of the Spotlight documentation.

There's 2 answers to that question:

1. it works. Apple has supported Spotlight integration in CoreData through everything they've put spotlight through. (at least that's what I'm reading)

2. I'm evaluation if that is the case right now.


clearly, since day 01 (been using Coredata for other things since it was called something else, in the very first version of Mac OS X Server.) of CD and spotlight integration, Apple has pushed CD for document data. Spotlight integration is one of those things they give you for free but gave you a stack of books to read if you want it in other places. right now, it's obvious that Spotlight integration in CD has been upgraded a LOT in the last 3 years. you used to have to start from scratch and create a new target from a template. Now it's a check box in CD. Somebody has been paying attention to this. You're right though, there's no updated documentation. But there s no code to write eiether.



what about this?

document based CD app, where there is Only 1 window, where you can see and work with documents? I think that would end run around Most of the CD issues.

Well, unfortunately, if it's working "by magic" in the OS X standard template, you're on your own figuring out how to change it. :-/


Because creating an abitrary number of persistent stores, each with its own entity and one instance of that entity, is simple enough to create. But if there's AppKit magic involved...

Doesn't UIDocument or NSdocument support spotlight? Create a sublass and build your own filewrapper in it, write your metadata in the document using the custom filewrapper.


Just an idea 😉

no, NSDocument doesn't support Spotlight. That's not how Spotlight works. Spotlight has more in common with a web crawler than the mac os files system. it keeps it's own DB of metadata, that it finds in new/changed files. In order to make Spotlight aware that it can has some data, you build a plugin for your app. The plugin has a lot of rules, they make literally no sense, they've changed a lot since day 01, and no-one has published an accurate and comprehensive list. Almost pure guesswork at this point. 3rd parties used to be able to back into these rules by dissecting the Spotlight Plugin template project for CoreData, but that no longer exists (and the old approaches don't work), because Apple streamlined the process, and now CD is Magically supporting Spotlight, directly from checkboxes in the CD UI. Now CD Spotlight support is completely opaque, too much of it automated. Clearly if you want spotlight support, the message is to use CD.


After you build the plugin structure, which I have done -Spotlight recognises my plugin- you then need to advertise which properties are available as metadata. This is slightly better documented. It doesn't work. But it IS documented, and the documents have never been altered or show any signs of temporal changes. So, clearly something HAS changed, but it's not in the documentation. Once Spotlight can see which properties are available, it then asks the PLUGIN, one property at a time, for the metadata. Since, we're writing a plugin... and this is the point of Spotlight... you have to open your file, extract the data, and then close the file. IE: spotlight doesn't ever interact with already opened files.


I just checked NSDocument. There's no mention at all of Spotlight. I'm not terribly surprised. Apple sometimes does pull something like that off, but it's such a bad fit, that I didn't really expect it.


a FileWrapper would be unable to address the Spotlight data of your document.


i appreciate the sentiment, but if it were that easy, I would have done it by now.

There's an old saying from The NEXT days: if it's difficult, then your are doing it wrong. Those days are LONG gone. I am trying to find an easier way, but only because the difficult way has been made impossible. Apple broke Spotlight when they introduced the sandbox, and they are still just staring at the peices.

multiple persistent stores, can I have one for each entity?
 
 
Q