Spotlight Query: can't get relevant relevance

  • Hello,

    I need to get the relevance of a query item.

    I think the values I get are wrong.

    Here is the code:

    NSPredicate *p = [NSPredicate
    predicateWithFormat:@"kMDItemTextContent LIKE[c] \"apple\" AND
    kMDItemContentTypeTree == \"com.adobe.pdf\""];
    [query setPredicate:p];
    [query setValueListAttributes:[NSArray arrayWithObjects:(NSString
    *)kMDQueryResultContentRelevance, nil]];
    [query startQuery];

    // ...

    NSNumber *relevance = [query
    valueOfAttribute:NSMetadataQueryResultContentRelevanceAttribute
    forResultAtIndex:i];

    Problem 1:

    According to NSMetadataQuery Class Reference: "An NSNumber object with
    a floating point value between 0.0 and 1.0 inclusive."

    The relevance I get is always between 0.10000 and 0.10002, for every
    predicate I run.

    So, it is not wrong according to the API, but these values let me
    think I do not write what I should.

    Problem 2:

    In the arguments of [query setValueListAttributes:] I wonder why I
    have to use kMDQueryResultContentRelevance.

    If I use NSMetadataQueryResultContentRelevanceAttribute the relevance
    is null.

    If I ask the query for its attribute kMDQueryResultContentRelevance,
    the relevance is the same, between 0.10000 and 0.10002.

    How can I get relevant relevance? :-)

    --
    Nicolas Seriot
    http://seriot.ch
previous month december 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Go to today