The query requires an index. You can create it here: {link is broken}
I'm querying against my "GroupConvos" collection where the documents all have a memberIds
string array with Ids about members that belong to that group and doing the following query for GroupConvos
gives me with a broken link
self.db.collection(kGroupConvos)
.order(by: kUpdatedAt, descending: true)
.whereField("memberIds", arrayContains: self.currentUserId)
.limit(to: 20)
.getDocuments { [weak self] snapshot, error in
if let error = error {
print(error)
} else { ... }
The query requires an index. You can create it here: {link}
Image:
So I went into the console and created an index:
And I keep getting that same error when I do my query. Any suggestions as to what to do here?
swift google-cloud-firestore firebase-console
add a comment |
I'm querying against my "GroupConvos" collection where the documents all have a memberIds
string array with Ids about members that belong to that group and doing the following query for GroupConvos
gives me with a broken link
self.db.collection(kGroupConvos)
.order(by: kUpdatedAt, descending: true)
.whereField("memberIds", arrayContains: self.currentUserId)
.limit(to: 20)
.getDocuments { [weak self] snapshot, error in
if let error = error {
print(error)
} else { ... }
The query requires an index. You can create it here: {link}
Image:
So I went into the console and created an index:
And I keep getting that same error when I do my query. Any suggestions as to what to do here?
swift google-cloud-firestore firebase-console
If you find a bug in the console, please file a bug report with reproduction steps: firebase.google.com/support/contact/bugs-features
– Doug Stevenson
Nov 20 at 22:40
Submitted for you all. In the meantime while that auto-create index bug is fixed, do you have a recommendation for either my query or my index to make this work and avoid the error?
– Zack Shapiro
Nov 20 at 22:55
add a comment |
I'm querying against my "GroupConvos" collection where the documents all have a memberIds
string array with Ids about members that belong to that group and doing the following query for GroupConvos
gives me with a broken link
self.db.collection(kGroupConvos)
.order(by: kUpdatedAt, descending: true)
.whereField("memberIds", arrayContains: self.currentUserId)
.limit(to: 20)
.getDocuments { [weak self] snapshot, error in
if let error = error {
print(error)
} else { ... }
The query requires an index. You can create it here: {link}
Image:
So I went into the console and created an index:
And I keep getting that same error when I do my query. Any suggestions as to what to do here?
swift google-cloud-firestore firebase-console
I'm querying against my "GroupConvos" collection where the documents all have a memberIds
string array with Ids about members that belong to that group and doing the following query for GroupConvos
gives me with a broken link
self.db.collection(kGroupConvos)
.order(by: kUpdatedAt, descending: true)
.whereField("memberIds", arrayContains: self.currentUserId)
.limit(to: 20)
.getDocuments { [weak self] snapshot, error in
if let error = error {
print(error)
} else { ... }
The query requires an index. You can create it here: {link}
Image:
So I went into the console and created an index:
And I keep getting that same error when I do my query. Any suggestions as to what to do here?
swift google-cloud-firestore firebase-console
swift google-cloud-firestore firebase-console
edited Nov 20 at 20:42
Frank van Puffelen
226k27368395
226k27368395
asked Nov 20 at 20:38
Zack Shapiro
1,08183983
1,08183983
If you find a bug in the console, please file a bug report with reproduction steps: firebase.google.com/support/contact/bugs-features
– Doug Stevenson
Nov 20 at 22:40
Submitted for you all. In the meantime while that auto-create index bug is fixed, do you have a recommendation for either my query or my index to make this work and avoid the error?
– Zack Shapiro
Nov 20 at 22:55
add a comment |
If you find a bug in the console, please file a bug report with reproduction steps: firebase.google.com/support/contact/bugs-features
– Doug Stevenson
Nov 20 at 22:40
Submitted for you all. In the meantime while that auto-create index bug is fixed, do you have a recommendation for either my query or my index to make this work and avoid the error?
– Zack Shapiro
Nov 20 at 22:55
If you find a bug in the console, please file a bug report with reproduction steps: firebase.google.com/support/contact/bugs-features
– Doug Stevenson
Nov 20 at 22:40
If you find a bug in the console, please file a bug report with reproduction steps: firebase.google.com/support/contact/bugs-features
– Doug Stevenson
Nov 20 at 22:40
Submitted for you all. In the meantime while that auto-create index bug is fixed, do you have a recommendation for either my query or my index to make this work and avoid the error?
– Zack Shapiro
Nov 20 at 22:55
Submitted for you all. In the meantime while that auto-create index bug is fixed, do you have a recommendation for either my query or my index to make this work and avoid the error?
– Zack Shapiro
Nov 20 at 22:55
add a comment |
2 Answers
2
active
oldest
votes
If you're using array-contains to search a field, it looks like you need to add an Array Contains type index to it:
Notice that you have an option for that. It looks like what you did instead was make memberIds an Ascending type field index.
Thanks Doug. I must have missed that option yesterday. Currently speaking with support about the console issue so hopefully that's ironed out soon. Have a good Thanskgiving!
– Zack Shapiro
Nov 21 at 17:10
add a comment |
For anyone interested, the correct index to prevent the index error for this query is:
arrayField: arrayContains
updatedAt: descending
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53401144%2fthe-query-requires-an-index-you-can-create-it-here-link-is-broken%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you're using array-contains to search a field, it looks like you need to add an Array Contains type index to it:
Notice that you have an option for that. It looks like what you did instead was make memberIds an Ascending type field index.
Thanks Doug. I must have missed that option yesterday. Currently speaking with support about the console issue so hopefully that's ironed out soon. Have a good Thanskgiving!
– Zack Shapiro
Nov 21 at 17:10
add a comment |
If you're using array-contains to search a field, it looks like you need to add an Array Contains type index to it:
Notice that you have an option for that. It looks like what you did instead was make memberIds an Ascending type field index.
Thanks Doug. I must have missed that option yesterday. Currently speaking with support about the console issue so hopefully that's ironed out soon. Have a good Thanskgiving!
– Zack Shapiro
Nov 21 at 17:10
add a comment |
If you're using array-contains to search a field, it looks like you need to add an Array Contains type index to it:
Notice that you have an option for that. It looks like what you did instead was make memberIds an Ascending type field index.
If you're using array-contains to search a field, it looks like you need to add an Array Contains type index to it:
Notice that you have an option for that. It looks like what you did instead was make memberIds an Ascending type field index.
answered Nov 20 at 23:48
Doug Stevenson
69.3k880101
69.3k880101
Thanks Doug. I must have missed that option yesterday. Currently speaking with support about the console issue so hopefully that's ironed out soon. Have a good Thanskgiving!
– Zack Shapiro
Nov 21 at 17:10
add a comment |
Thanks Doug. I must have missed that option yesterday. Currently speaking with support about the console issue so hopefully that's ironed out soon. Have a good Thanskgiving!
– Zack Shapiro
Nov 21 at 17:10
Thanks Doug. I must have missed that option yesterday. Currently speaking with support about the console issue so hopefully that's ironed out soon. Have a good Thanskgiving!
– Zack Shapiro
Nov 21 at 17:10
Thanks Doug. I must have missed that option yesterday. Currently speaking with support about the console issue so hopefully that's ironed out soon. Have a good Thanskgiving!
– Zack Shapiro
Nov 21 at 17:10
add a comment |
For anyone interested, the correct index to prevent the index error for this query is:
arrayField: arrayContains
updatedAt: descending
add a comment |
For anyone interested, the correct index to prevent the index error for this query is:
arrayField: arrayContains
updatedAt: descending
add a comment |
For anyone interested, the correct index to prevent the index error for this query is:
arrayField: arrayContains
updatedAt: descending
For anyone interested, the correct index to prevent the index error for this query is:
arrayField: arrayContains
updatedAt: descending
answered Nov 21 at 17:37
Zack Shapiro
1,08183983
1,08183983
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53401144%2fthe-query-requires-an-index-you-can-create-it-here-link-is-broken%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
If you find a bug in the console, please file a bug report with reproduction steps: firebase.google.com/support/contact/bugs-features
– Doug Stevenson
Nov 20 at 22:40
Submitted for you all. In the meantime while that auto-create index bug is fixed, do you have a recommendation for either my query or my index to make this work and avoid the error?
– Zack Shapiro
Nov 20 at 22:55