Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8112043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:20:20+00:00 2026-06-06T02:20:20+00:00

OS X’s Search Kit Framework allows to create and access search indexes. However, it

  • 0

OS X’s Search Kit Framework allows to create and access search indexes. However, it is not possible to access an existing search index when the name of that index is unknown. All functions of the framework which may be used to access an existing search index (SKIndexOpenWithData, SKIndexOpenWithMutableData, SKIndexOpenWithURL) ask for the index name. This is not the same as the file name of the file in which the search index data is stored.

When I try to access an existing search index file by calling SKIndexOpenWithURL without knowing the name of the index, the function doesn’t return a valid SKIndexRef. Passing NULL as index name (as suggested by the framework’s documentation) doesn’t work because then the Search Kit Framework only tries to use an index name of ‘IADefaultIndex’.

As an example, if I create an index file with an index name like this:

    NSString *path = @"/Users/Tim/Desktop/searchindex.skindex";
    NSURL *url = [NSURL fileURLWithPath: path];  
    NSString *name = @"myIndex";          
    SKIndexType type = kSKIndexInverted;                    
    SKIndexRef skIndex;
    skIndex = SKIndexCreateWithURL ((__bridge CFURLRef)url, (__bridge CFStringRef)name, (SKIndexType)type, (CFDictionaryRef)NULL);
    // ..

I can later only open the file and access the stored index if I know the index name “myIndex”. If I try to open the file without having (or knowing) the index name, the following code sample will fail:

    NSURL *skURL = [NSURL fileURLWithPath:@"/Users/Tim/Desktop/searchindex.skindex"];
    SKIndexRef skIndex;
    skIndex = SKIndexOpenWithURL((__bridge CFURLRef)skURL, NULL, true);
    if (!skIndex) NSLog (@"couldn't open index!");

However, the name of the search index is surely inside that index file. Does anybody know of a way to retrieve that name or to otherwise access a search index file without knowing the search index name? I’m aware that according to the framework documentation there is no possibility of using the framework to get that index name, but it should nevertheless be possible.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T02:20:22+00:00Added an answer on June 6, 2026 at 2:20 am

    Ok, after some research I figured out how to extract the index name from a search index file:

    -(NSString*)getIndexNameOfSKFile:(NSString*)filePath
    {
        if (!filePath) return nil;
    
        // open the search index file
        NSData *data = [NSData dataWithContentsOfFile:filePath];
        if (!data) return nil;
        NSUInteger dataLength = [data length];
    
        // calculate the offset where the index name is stored
        int32_t offset1, offset2;
        if (dataLength<11) return nil;
        [data getBytes:&offset1 range:NSMakeRange(4,4)];
        [data getBytes:&offset2 range:NSMakeRange(8,4)];
        int32_t offset = CFSwapInt32HostToBig(offset1)+(CFSwapInt32HostToBig(offset2)/2)+14;
    
        // Get index name string (stored as zero-terminated string)
        unichar c;
        NSMutableString *indexName = [NSMutableString stringWithCapacity:0];
        do {
            if (dataLength<(offset+1)) return nil;
            [data getBytes:&c range:NSMakeRange(offset, 2)];
            if (c!=0) [indexName appendString:[NSString stringWithCharacters:&c length:1]];
            offset+=2;
        } while (c!=0);
        return indexName;
    }
    

    This may not work for every OS X version, but it is working for me with 10.7.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.