CloudKit Unexpected Expression for NSPredicate

deepkanwal

I'm using CloudKit and wish to perform a search for records based on their string fields.

Apple docs say this is the way to do a tokenized search of a record's fields:

To perform a tokenized search of a record’s fields, use the special operator self. A tokenized search searches any fields that have full-text search enabled, which is all string-based fields by default. Listing 5 shows an example that searches the fields of the record for the token strings bob and smith. Each distinct word is treated as a separate token for the purpose of searching. Comparisons are case- and diacritic-insensitive. These token strings may be found in a single field or in multiple fields but all of the tokens must be present in a record for it to be considered a match.

Listing 5: Matching a field containing a tokenized string

NSPredicate predicate = nil;
predicate = [NSPredicate predicateWithFormat:@"self contains 'bob smith'"];

When I enter this exact string for the predicate, I get the an exception.

Code:

predicate = [NSPredicate predicateWithFormat:@"self contains 'bob smith'"];
query = [[CKQuery alloc] initWithRecordType:kCKRecord_Level predicate:predicate];

Exception:

*** Terminating app due to uncaught exception 'CKException', reason: 'Unexpected expression: SELF CONTAINS "bob smith"'

Any ideas what could be wrong? Has anyone had any success with that predicate string and CloudKit?

https://developer.apple.com/library/prerelease/ios/documentation/CloudKit/Reference/CKQuery_class/index.html

Edwin Vermeer

It looks like the 'self contains' does not work anymore. You still do a tokenized search using this predicate:

NSPredicate(format: "allTokens TOKENMATCHES[cdl] %@", "bob smith")

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Using NSPredicate with array for cloudKit search

From Dev

NSPredicate case insensitive string search with CloudKit

From Dev

NSPredicate and BEGINSWITH with CloudKit : Field value type mismatch

From Dev

CloudKit - NSPredicate for finding all records that contains multiple CKReferences in a reference list

From Dev

CloudKit - NSPredicate for finding all records that contain specified CKReference in a reference list

From Dev

How to fetch the latest Post for specific users using NSPredicate and CloudKit?

From Dev

NSPredicate expression to filter on count of a to-many relationship

From Dev

Unexpected end of expression

From Dev

Regular Expression - Unexpected Quantifier

From Dev

Unexpected matlab expression in function

From Dev

unexpected end of regular expression

From Dev

JSLint: Unexpected assignment expression

From Dev

Unexpected token in expression or statement

From Java

Unexpected behaviour with a conditional generator expression

From Dev

JavaScript regular expression unexpected behavior

From Dev

Unexpected '.' from wrapped expression to chain

From Dev

Unexpected token 'server' in expression or statement

From Dev

ERROR : Syntax error in expression (unexpected `|')

From Dev

Unexpected behaviour with a conditional generator expression

From Dev

Unexpected result from math expression

From Dev

Unexpected token 'server' in expression or statement

From Dev

unexpected token 'if' in expression or statement powershell

From Dev

unexpected end of regular expression in python

From Dev

NSPredicate Regular Expression to match more than one segment on the same attribute

From Dev

Unexpected result of subtracting a NASM macro in an expression

From Dev

Unexpected DO-WHILE behavior: Is it ignoring the expression?

From Dev

Unexpected unsymmetrical regular expression behavior of \< and \> in R

From Dev

Unexpected Regular expression result using dot symbol

From Dev

Unexpected promotion to 'complex' type in Python math expression

Related Related

  1. 1

    Using NSPredicate with array for cloudKit search

  2. 2

    NSPredicate case insensitive string search with CloudKit

  3. 3

    NSPredicate and BEGINSWITH with CloudKit : Field value type mismatch

  4. 4

    CloudKit - NSPredicate for finding all records that contains multiple CKReferences in a reference list

  5. 5

    CloudKit - NSPredicate for finding all records that contain specified CKReference in a reference list

  6. 6

    How to fetch the latest Post for specific users using NSPredicate and CloudKit?

  7. 7

    NSPredicate expression to filter on count of a to-many relationship

  8. 8

    Unexpected end of expression

  9. 9

    Regular Expression - Unexpected Quantifier

  10. 10

    Unexpected matlab expression in function

  11. 11

    unexpected end of regular expression

  12. 12

    JSLint: Unexpected assignment expression

  13. 13

    Unexpected token in expression or statement

  14. 14

    Unexpected behaviour with a conditional generator expression

  15. 15

    JavaScript regular expression unexpected behavior

  16. 16

    Unexpected '.' from wrapped expression to chain

  17. 17

    Unexpected token 'server' in expression or statement

  18. 18

    ERROR : Syntax error in expression (unexpected `|')

  19. 19

    Unexpected behaviour with a conditional generator expression

  20. 20

    Unexpected result from math expression

  21. 21

    Unexpected token 'server' in expression or statement

  22. 22

    unexpected token 'if' in expression or statement powershell

  23. 23

    unexpected end of regular expression in python

  24. 24

    NSPredicate Regular Expression to match more than one segment on the same attribute

  25. 25

    Unexpected result of subtracting a NASM macro in an expression

  26. 26

    Unexpected DO-WHILE behavior: Is it ignoring the expression?

  27. 27

    Unexpected unsymmetrical regular expression behavior of \< and \> in R

  28. 28

    Unexpected Regular expression result using dot symbol

  29. 29

    Unexpected promotion to 'complex' type in Python math expression

HotTag

Archive