13

In Cloudkit Dashboard, I select Record Type, Edit Indexes, then I select Add Basic Index. I see in the dropdown createTime, createdBy, eTag, modTime, modifiedBy, recordID and the record fields. I do not see recordName in the dropdown( Attached screenshot). Without creating index on recordName, I cannot query the record in cloudKit Dashboard. I get error: Field 'recordName' is not marked queryable How to create index on recordName? screen shot of crete index

vrao
  • 545
  • 2
  • 12
  • 33

2 Answers2

12

I ran into this same issue and solved it by adding ___recordID as a queryable index. When it is added to the list of indexes, the field changes to recordName.

To add this as a queryable index, go to the Schema Section -> Indexes, and click Add Basic Index.

kschins
  • 1,054
  • 1
  • 13
  • 26
  • That worked for me. I am a CloudKit newbie, so I think it's worth pointing out that it is under the Schema Section -> Indexes and select _Add Basic Index_. In the drop down you should see __recordID as pointed out by kschins – Jav Solo Oct 22 '21 at 20:29
  • Great comment, @javsolo. I will update my answer with the pertinent information and a screenshot. – kschins Oct 23 '21 at 00:09
  • Adding index on private database, enable us to browse the data, during development stage. However, will such operation affected other user production data? Should we undo such operation, before we deploy the production? – Cheok Yan Cheng Jun 10 '22 at 05:03
6

Here is a visual of how to do it in the dashboard. Pay attention to the photos with steps 8) and 18).

FYI after doing the below I ran into another issue where I got an error

Field 'createdBy' is not marked queryable

I'm not sure which one is createdBy but to fix it I had to follow the same exact steps below except on step 14), I choose createdUserRecordName and all the other system generated field names like __etag etc and then had to make sure each one was 15 )queryable. I had to press 16) Save Changes for each one separately.

A- Select 1) Databases > 2) click the dropdown arrow 3) select your iCloud name from 4) Xcode

enter image description here

enter image description here

B- Next select 5) Records (press the drop down arrow) > 6) Schema > Record Types (after Record Types highlights click anywhere off of the screen)

enter image description here

enter image description here

C- Next under 7) Record Type click Users or whatever the name of your record type is

enter image description here

D- On the next screen you will will see 8) the recordName field is set to None under Single Field Indexes. To change it and fix the issue press 9) Record Types to go back

enter image description here

E- After you went back a page, on that same page 10) press the down arrow next to Records > then 11) select Schema > Indexes (after Indexes highlights click anywhere off of the screen)

enter image description here

enter image description here

F- Next under 12) Record Type click Users or whatever the name of your record type is

enter image description here

G- On this page, at the bottom, 13) click Add Basic Index and then select 14) recordName

enter image description here

enter image description here

H- On that same page, make sure that 15) the Index Type is Queryable. Then press 16) Save Changes. After it saves, press 17) Indexes to go back

enter image description here

Follow steps 5) to 8) again, but this time 18) the recordName field will be set to **Queryable** under Single Field Indexes

enter image description here

Lance Samaria
  • 17,576
  • 18
  • 108
  • 256