Next Page > Hide TOC

Legacy Documentclose button

Important: The Find by Content API is deprecated as of Mac OS X v10.4. A much more complete solution for finding and displaying information is provided by the Search Kit. See Search Kit Programming Guide for guidelines on using the Search Kit.

Find By Content Reference (Not Recommended)

Framework
ApplicationServices/ApplicationServices.h
Declared in
FindByContent.h

Overview

Important: The Find by Content API is deprecated as of Mac OS X v10.4. A much more complete solution for finding and displaying information is provided by the Search Kit. See Search Kit Programming Guide for guidelines on using the Search Kit.

Whereas the Find by Content API searches specified volumes or folders for words typed in by a user, Search Kit uses a much faster fully indexed search to return relevant content of all sorts. Because the Search Kit takes a different approach to searching for and displaying information from that used by the Find by Content API, you cannot make a one-to-one substitution of Seach Kit functions for Find by Content functions. However, the basic features of the Search Kit can be implemented very quickly, and Search Kit offers much greater capability than the Find by Content API.

Previous to Mac OS X version 10.2, the main client for Find by Content was Sherlock; in versions 10.2 and 10.3 it was the Finder. In version 10.4 and later, Search Kit is used instead by the Finder, Mail, and Spotlight.

Carbon supports Find By Content, but note that it is not contained within the Carbon framework.

Functions by Task

Working With Indexes

Setting Up a Search Session Object

Executing a Search

Getting Information About Search Session Hits

Deallocating Hit Lists and Search Sessions

Summarizing Text

Working with Universal Procedure Pointers

Deprecated Functions

Callbacks

FBCCallbackProcPtr

Defines a pointer to a function that can cancel a search operation.

typedef Boolean (*FBCCallbackProcPtr)
(
   UInt16 phase,
   float percentDone,
   void * data
);

If you name your function MyFBCCallbackProc, you would declare it like this:

Boolean MyFBCCallbackProcPtr (
   UInt16 phase,
   float percentDone,
   void * data
);

Parameters
phase
percentDone
data

A pointer to data needed by your callback. This is the same data you provided to the function FBCSetSessionCallback in the data parameter.

Return Value

Return true if you wants to cancel the current operation. Otherwise return false.

Discussion

Find by Content invoke your callback periodically (approximately every 5 ticks) while searching. Your callback can cancel a search operation by returning a value of true.

Availability
Declared In
FindByContent.h

FBCHitTestProcPtr

Defines a pointer to a function that performs search-hit testing.

typedef Boolean (*FBCHitTestProcPtr)
(
   const FSRef * theFile,
   void * data
);

If you name your function MyFBCHitTestProc, you would declare it like this:

Boolean MyFBCHitTestProcPtr (
   const FSRef * theFile,
   void * data
);

Parameters
theFile

A pointer to an FSRef that specifies the location of file that matches the search query.

data

A pointer to data needed by your callback. This is the same data you provided to the function FBCSetSessionHitTest in the data parameter.

Return Value

Return true if your callback wants to accept the file as a valid match or false to reject it.

Discussion

You can use this callback to impose additional matching criteria in addition to that provided to Find by Content. For example, you could accept a hit only if the file has a creation date later than a specified date.

Availability
Declared In
FindByContent.h

Data Types

FBCCallbackUPP

Defines a universal procedure pointer to a search cancellation callback.

typedef FBCCallbackProcPtr FBCCallbackUPP;

Discussion

For more information, see the description of the FBCCallbackProcPtr callback function.

Availability
Declared In
FindByContent.h

FBCHitTestUPP

Defines a universal procedure pointer to a search-hit testing callback.

typedef FBCHitTestProcPtr FBCHitTestUPP;

Discussion

For more information, see the description of the FBCHitTestProcPtr callback function.

Availability
Declared In
FindByContent.h

FBCSearchSession

Defines pointer to an opaque data type (referred to as a search session object) that contains a collection of state information used in a search session.

typedef struct OpaqueFBCSearchSession * FBCSearchSession;

Discussion

You call the function FBCCreateSearchSessionto create a new search session object. When no longer need the search session object, you must dispose of it by calling the function FBCDestroySearchSession.

Availability
Declared In
FindByContent.h

FBCSummaryRef

A pointer to an opaque data type (referred to as a summary reference object) that contains summary information, from which summary text can be obtained.

typedef struct OpaqueFBCSummaryRef * FBCSummaryRef;

Discussion

You call the function FBCGetSummaryOfCFStringto create a new summary reference object. When no longer need the summary reference object, you must dispose of it by calling the function FBCDisposeSummary.

Availability
Declared In
FindByContent.h

FBCWordItem

Defines a data type for an ordinary C string used for searching.

typedef char* FBCWordItem;

Availability
Declared In
FindByContent.h

FBCWordList

Defines an array of word items.

typedef FBCWordItem * FBCWordList;

Availability
Declared In
FindByContent.h

Constants

Language Constants

Define values for language constants.

enum {
   kFBCenglishHighWord = 0x80000000,
   kFBCdutchHighWord = 0x40000000,
   kFBCgermanHighWord = 0x20000000,
   kFBCswedishHighWord = 0x10000000,
   kFBCdanishHighWord = 0x08000000,
   kFBCspanishHighWord = 0x04000000,
   kFBCportugueseHighWord = 0x02000000,
   kFBCitalianHighWord = 0x01000000,
   kFBCfrenchHighWord = 0x00800000,
   kFBCromanHighWord = 0x00400000,
   kFBCicelandicHighWord = 0x00200000,
   kFBChebrewHighWord = 0x00100000,
   kFBCarabicHighWord = 0x00080000,
   kFBCcenteuroHighWord = 0x00040000,
   kFBCcroatianHighWord = 0x00020000,
   kFBCturkishHighWord = 0x00010000,
   kFBCromanianHighWord = 0x00008000,
   kFBCgreekHighWord = 0x00004000,
   kFBCcyrillicHighWord = 0x00002000,
   kFBCdevanagariHighWord = 0x00001000,
   kFBCgujuratiHighWord = 0x00000800,
   kFBCgurmukhiHighWord = 0x00000400,
   kFBCjapaneseHighWord = 0x00000200,
   kFBCkoreanHighWord = 0x00000100,
   kFBCdefaultLanguagesHighWord = 0xFF800000
};

Discussion

Language constants are passed as parameters to the function FBCIndexItemsInLanguages. The purpose of these constants is to tell Find by Content what languages the user expects the files to contain. From this, Find by Content infer the character encodings to look for, and for some languages, what lists of words to exclude from the index and what rules to use in reducing words to their stems.

These constants are bits in a 64-bit array that consists of two UInt32 words. In the current implementation the low word is always 0, so values for the high word are given. If both UInt32 words are 0, the default value of kDefaultLanguagesHighWord is used.

Phase Values

Define values that are passed to a progress callback function to indicate what phase of an operation Find By Content is currently performing; most of these values are not used in Mac OS X.

enum {
   kFBCphIndexing = 0,
   kFBCphFlushing = 1,
   kFBCphMerging = 2,
   kFBCphMakingIndexAccessor = 3,
   kFBCphCompacting = 4,
   kFBCphIndexWaiting = 5,
   kFBCphSearching = 6,
   kFBCphMakingAccessAccessor = 7,
   kFBCphAccessWaiting = 8,
   kFBCphSummarizing = 9,
   kFBCphIdle = 10,
   kFBCphCanceling = 11
};

Constants
kFBCphIndexing

Indicates an indexing phase. This is no longer used in Mac OS X.

Available in Mac OS X v10.0 through Mac OS X v10.4.

Declared in FindByContent.h.

kFBCphFlushing

Indicates an indexing phase. This is no longer used in Mac OS X.

Available in Mac OS X v10.0 through Mac OS X v10.4.

Declared in FindByContent.h.

kFBCphMerging

Indicates an indexing phase. This is no longer used in Mac OS X.

Available in Mac OS X v10.0 through Mac OS X v10.4.

Declared in FindByContent.h.

kFBCphMakingIndexAccessor

Indicates an indexing phase. This is no longer used in Mac OS X.

Available in Mac OS X v10.0 through Mac OS X v10.4.

Declared in FindByContent.h.

kFBCphCompacting

Indicates an indexing phase. This is no longer used in Mac OS X.

Available in Mac OS X v10.0 through Mac OS X v10.4.

Declared in FindByContent.h.

kFBCphIndexWaiting

Indicates an access phase. This is no longer used in Mac OS X.

Available in Mac OS X v10.0 through Mac OS X v10.4.

Declared in FindByContent.h.

kFBCphSearching

Indicates searching phase. In Mac OS X, this is the only phase value returned to your FBCCallbackProcPtr callback.

Available in Mac OS X v10.0 through Mac OS X v10.4.

Declared in FindByContent.h.

kFBCphMakingAccessAccessor

Indicates an access phase. This is no longer used in Mac OS X.

Available in Mac OS X v10.0 through Mac OS X v10.4.

Declared in FindByContent.h.

kFBCphAccessWaiting

Indicates an access phase. This is no longer used in Mac OS X.

Available in Mac OS X v10.0 through Mac OS X v10.4.

Declared in FindByContent.h.

kFBCphSummarizing

Indicates summarization. This is no longer used in Mac OS X.

Available in Mac OS X v10.0 through Mac OS X v10.4.

Declared in FindByContent.h.

kFBCphIdle

Indicates indexing or accessing. This is no longer used in Mac OS X.

Available in Mac OS X v10.0 through Mac OS X v10.4.

Declared in FindByContent.h.

kFBCphCanceling

Indicates cancellation. This is no longer used in Mac OS X.

Available in Mac OS X v10.0 through Mac OS X v10.4.

Declared in FindByContent.h.

Discussion

The values are meaningless in Mac OS X.

Deprecated Language Constants

Redefine old language constants as new ones; you should use the new value.

enum {
   englishHighWord = kFBCenglishHighWord,
   dutchHighWord = kFBCdutchHighWord,
   germanHighWord = kFBCgermanHighWord,
   swedishHighWord = kFBCswedishHighWord,
   danishHighWord = kFBCdanishHighWord,
   spanishHighWord = kFBCspanishHighWord,
   portugueseHighWord = kFBCportugueseHighWord,
   italianHighWord = kFBCitalianHighWord,
   frenchHighWord = kFBCfrenchHighWord,
   romanHighWord = kFBCromanHighWord,
   icelandicHighWord = kFBCicelandicHighWord,
   hebrewHighWord = kFBChebrewHighWord,
   arabicHighWord = kFBCarabicHighWord,
   centeuroHighWord = kFBCcenteuroHighWord,
   croatianHighWord = kFBCcroatianHighWord,
   turkishHighWord = kFBCturkishHighWord,
   romanianHighWord = kFBCromanianHighWord,
   greekHighWord = kFBCgreekHighWord,
   cyrillicHighWord = kFBCcyrillicHighWord,
   devanagariHighWord = kFBCdevanagariHighWord,
   gujuratiHighWord = kFBCgujuratiHighWord,
   gurmukhiHighWord = kFBCgurmukhiHighWord,
   japaneseHighWord = kFBCjapaneseHighWord,
   koreanHighWord = kFBCkoreanHighWord,
   kDefaultLanguagesHighWord = kFBCdefaultLanguagesHighWord
};

Result Codes

The result codes returned by Find By Content are listed below.

Result CodeValueDescription
errIANoErr 0

Available in Mac OS X v10.0 and later.

kFBCvTwinExceptionErr -30500

No telling what it was

Available in Mac OS X v10.0 and later.

kFBCnoIndexesFound -30501

Indexes not found

Available in Mac OS X v10.0 and later.

kFBCallocFailed -30502

Possibly due to low memory

Available in Mac OS X v10.0 and later.

kFBCbadParam -30503

Bad parameter passed to a function

Available in Mac OS X v10.0 and later.

kFBCfileNotIndexed -30504

File not indexed

Available in Mac OS X v10.0 and later.

kFBCbadIndexFile -30505

Bad FSSpec, or bad data in file

Available in Mac OS X v10.0 and later.

kFBCcompactionFailed -30506

V-Twin exception caught

Available in Mac OS X v10.0 and later.

kFBCvalidationFailed -30507

V-Twin exception caught

Available in Mac OS X v10.0 and later.

kFBCindexingFailed -30508

V-Twin exception caught

Available in Mac OS X v10.0 and later.

kFBCcommitFailed -30509

V-Twin exception caught

Available in Mac OS X v10.0 and later.

kFBCdeletionFailed -30510

V-Twin exception caught

Available in Mac OS X v10.0 and later.

kFBCmoveFailed -30511

V-Twin exception caught

Available in Mac OS X v10.0 and later.

kFBCtokenizationFailed -30512

Couldn't read from document or query

Available in Mac OS X v10.0 and later.

kFBCmergingFailed -30513

Couldn't merge index files

Available in Mac OS X v10.0 and later.

kFBCindexCreationFailed -30514

Couldn't create index

Available in Mac OS X v10.0 and later.

kFBCaccessorStoreFailed -30515

Available in Mac OS X v10.0 and later.

kFBCaddDocFailed -30516

Available in Mac OS X v10.0 and later.

kFBCflushFailed -30517

Available in Mac OS X v10.0 and later.

kFBCindexNotFound -30518

Index not found

Available in Mac OS X v10.0 and later.

kFBCnoSearchSession -30519

Search session object not created

Available in Mac OS X v10.0 and later.

kFBCindexingCanceled -30520

Indexing cancelled

Available in Mac OS X v10.0 and later.

kFBCaccessCanceled -30521

Available in Mac OS X v10.0 and later.

kFBCindexFileDestroyed -30522

Index file destroyed

Available in Mac OS X v10.0 and later.

kFBCindexNotAvailable -30523

Index not available

Available in Mac OS X v10.0 and later.

kFBCsearchFailed -30524

Search failed

Available in Mac OS X v10.0 and later.

kFBCsomeFilesNotIndexed -30525

Some files are not indexed

Available in Mac OS X v10.0 and later.

kFBCillegalSessionChange -30526

Tried to add/remove volumes to a session.

Available in Mac OS X v10.0 and later.

kFBCanalysisNotAvailable -30527

Available in Mac OS X v10.0 and later.

kFBCbadIndexFileVersion -30528

Available in Mac OS X v10.0 and later.

kFBCsummarizationCanceled -30529

Summarization operation cancelled

Available in Mac OS X v10.0 and later.

kFBCindexDiskIOFailed -30530

Available in Mac OS X v10.0 and later.

kFBCbadSearchSession -30531

Available in Mac OS X v10.0 and later.

kFBCnoSuchHit -30532

Hit doesn’t exist

Available in Mac OS X v10.0 and later.

kFBCsummarizationFailed -30533

Summarization operation failed

Available in Mac OS X v10.2 through Mac OS X v10.4.

kFBCnotAllFoldersSearchable -30533

Not all folders are searchable

Available in Mac OS X v10.2 through Mac OS X v10.4.



Next Page > Hide TOC


© 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-07-13)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.