문제

I'm using Spotlight APIs to provide search in my application. I need to know the no of times the search string is present in a file so that I can implement a Sort Descriptor and sort the results. Is there any way to do this without having to open every file? Other libraries like Lucene give relevance rating which is very useful.

도움이 되었습니까?

해결책

You can ask your metadata query result items for the value of the NSMetadataQueryResultContentRelevanceAttribute key.

This will return an NSNumber object with a floating point value between 0.0 and 1.0 inclusive.

The relevance value indicates the relevance of the content of the result object.

You can't access the actual number of times your string is present in each search result.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top