Core Spotlight search query returns partly non-matching results

Originator:n.morev
Number:rdar://32944805 Date Originated:June 23 2017, 1:13 PM
Status:Closed Resolved:
Product:iOS SDK Product Version:9.0 beta (9M136h)
Classification:Core Spotlight Reproducible:Always
 
Area:
Core Spotlight

Summary:
CSSearchQuery with filter by metadataModificationDate range returns some results that match that query and some that don't.

Steps to Reproduce:
1. Populate Core Spotlight index with some objects. Set metadataModificationDate of CSSearchableItemAttributeSet to some date values.
2. Create CSSearchQuery object with the following query:
> po [query valueForKey:@"queryString"]
(accountIdentifier == "strongscented@mail.ru" && (textContent == "twitter"cdwt || (recipientNames == "twitter"cdwt || recipientEmailAddresses == "twitter"cdwt) || (authorNames == "twitter"cdwt || authorEmailAddresses == "twitter"cdwt) || subject == "twitter"cdwt) && (metadataModificationDate >= 519771600 && metadataModificationDate <= 519904626))

The last part of the query contains conditions to match objects with dates between Jun 22, 2017 and Jun 23, 2017.

3. Observe returned results in query.completionHandler:

> po [[allResults valueForKey:@"attributeSet"] valueForKey:@"metadataModificationDate"]
<__NSArrayI 0x608011047da0>(
2017-06-19 15:35:03 +0000,
2017-06-17 17:05:50 +0000,
2017-05-18 14:15:43 +0000,
2017-05-17 17:41:58 +0000,
2017-06-16 14:32:31 +0000,
2015-02-09 11:37:11 +0000,
2017-06-16 21:06:21 +0000,
2017-06-22 16:04:17 +0000,
2017-06-21 14:58:21 +0000,
2017-06-22 20:30:41 +0000,
2017-06-20 17:30:13 +0000,
2016-12-01 13:35:26 +0000,
2017-06-19 20:38:41 +0000,
2017-06-18 14:40:38 +0000,
2015-07-22 18:44:36 +0000
)

Expected Results:
The results contain only objects with metadataModificationDate matching date range in query.

Observed Results:
The results contain objects with metadataModificationDate outside queried date range.

Version:
Version 9.0 beta (9M136h)
iOS 11 beta 1, iPhone 7 Plus Simulator

Notes:


Configuration:

Comments

Fixed in Xcode 9 beta 3. Now metadataModificationDate set by you automatically overrided to current date.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!