• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSMetadataQueryResultContentRelevanceAttribute?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMetadataQueryResultContentRelevanceAttribute?


  • Subject: Re: NSMetadataQueryResultContentRelevanceAttribute?
  • From: Chris Kane <email@hidden>
  • Date: Mon, 4 Jul 2005 18:00:50 -0700

From my understanding, ....

I don't know what your query looks like in this case, but "ContentRelevance" only applies to queries with a single text content expression. This is because the Relevance is computed by SearchKit, when Spotlight uses it to do the Content bit of the query. Anything the docs say about [the nature of] relevance with SearchKit probably also applies to this attribute, since it just comes from SearchKit. It may be worth looking that up, as relevance may not necessarily mean what you (or anyone) thinks it means; I don't know the specific SearchKit definition myself.

Further, if an item gets in the result set because it matches one or more clauses of the query other than the Content clause, then the Relevance may not be computed for the item because SearchKit hasn't been used to produce that match.

Next, NSMetadataQueryResultContentRelevanceAttribute is a query- specific attribute; that is, it's implemented by the query mechanism, not the item mechanism. You can't ask an item for its NSMetadataQueryResultContentRelevanceAttribute. Items may be shared by multiple queries, and they don't know anything about the context to which "relevance" applies. If I do a search for "fred" a given document will have one relevance, but if I search for ("bob" or "george") it might have a different relevance. You can use - valueOfAttribute:forResultAtIndex: on NSMetadataQuery to get the value.

The last tricky bit (I think) is that the Relevance is only computed if you have asked for it to be used in the sorting or value-list or grouping attributes. That is, unless you have asked for it in the query, SearchKit isn't told to compute it, and it isn't stored, for better performance. Just throw it into one of the three attribute lists, and it'll get computed with the query results.

Note that all of this is also true of the Metadata ("MD") C API, with different symbol names, where this stuff is actually implemented.


Chris Kane Cocoa Frameworks, Apple


On Jun 26, 2005, at 3:57 PM, Steve Gehrman wrote:


I can't seem to get NSMetadataQueryResultContentRelevanceAttribute working.


I'm not even sure I'm using it right.  The docs kind of blow.

Help!  relevanceNum is always nil.  What is wrong?

- (NSArray*)results;
{
    [[self query] disableUpdates];

    unsigned i, cnt = [[self query] resultCount];
    NSMetadataItem* item;
    NSString* path;
    NTFileDesc* desc;
    NSMutableArray* results = [NSMutableArray arrayWithCapacity:cnt];
    float relevance;

    for (i=0;i<cnt;i++)
    {
        item = [[self query] resultAtIndex:i];

path = [item valueForAttribute:(NSString*)kMDItemPath];
NSNumber* relevanceNum = [item valueForAttribute:NSMetadataQueryResultContentRelevanceAttribute];


        relevance = 1.0;
        if (relevanceNum)  // ###  alway nil !!!!!!!!!!!!!!!!
            relevance = [relevanceNum floatValue];

        if (path)
        {
            desc = [NTFileDesc descNoResolve:path];

[results addObject:[NTFindResult result:desc relevance:relevance]];
}
}


    [[self query] enableUpdates];

    return results;
}

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Prev by Date: Re: Reading data from an NSTask [SOLVED]
  • Next by Date: table binding/core data
  • Previous by thread: Re: Cocoa Globe/ShapeFile Library?
  • Next by thread: table binding/core data
  • Index(es):
    • Date
    • Thread