Re: SearchKit and SKIndexDocumentIterator
Re: SearchKit and SKIndexDocumentIterator
- Subject: Re: SearchKit and SKIndexDocumentIterator
- From: Stuart Halloway <email@hidden>
- Date: Wed, 3 Dec 2003 02:09:55 -0500
Hi Sebastian,
I just hit the same thing. The only 'solution' I found so far is to
work down the parent-child tree (see code below). The key is starting
with NULL, then passing each found document back to
SKIndexDocumentIteratorCreate.
The SearchKit API begs for a convenience wrapper, which is odd -- one
of the things I have enjoyed about Cocoa so far is that most things are
already convenient. :-)
Stu
- (NSMutableArray*) addAllDocumentsFromIndex: (SKIndexRef) theIndex
iterator: (SKIndexDocumentIteratorRef) iter toArray: (NSMutableArray*)
array {
if (!array) {
array = [NSMutableArray arrayWithCapacity:8];
}
if (iter) {
CFRetain(iter);
} else {
iter = SKIndexDocumentIteratorCreate(theIndex,NULL);
}
SKDocumentRef doc;
while (doc = SKIndexDocumentIteratorCopyNext(iter)) {
[array addObject:(id)doc];
SKIndexDocumentIteratorRef subIter =
SKIndexDocumentIteratorCreate(theIndex,doc);
if (subIter)
array = [self addAllDocumentsFromIndex:theIndex
iterator:subIter toArray:array];
CFRelease(subIter);
CFRelease(doc);
}
CFRelease(iter);
return array;
}
Hello everybody,
so, I started using SearchKit. Indexing and searching works fine.
However, I need to iterate over all documents in an index. What I'm
currently doing is this:
// "index" is a valid reference to an index of documents
SKDocumentRef docRef = SKIndexCopyDocumentForDocumentID(index,
SKIndexGetMaximumDocumentID(index));
SKIndexDocumentIteratorRef iterator =
SKIndexDocumentIteratorCreate(index, docRef);
SKDocumentRef thisDoc = SKIndexDocumentIteratorCopyNext(iterator);
while (thisDoc != NULL)
{
// Do something with the document
CFRelease(thisDoc);
thisDoc = SKIndexDocumentIteratorCopyNext(iterator);
}
For clarification: I use SKIndexGetMaximumDocumentID() because this is
the only function I could find to get a reference to a concrete
document. I also tried NULL as an argument to
SKIndexDocumentIteratorCreate(), but whatever I do, it iterates over
_exactly one_ document, though SKIndexGetDocumentCount() returns 400
which seems about right.
Is there another way to get references to all documents in an index?
Or can anybody tell me what I'm doing wrong?
Any help is very much appreciated, I'm somewhat desperate.
Sebastian
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.