The query requires an index. You can create it here: {link is broken}












1














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:



enter image description here



So I went into the console and created an index:



enter image description here



And I keep getting that same error when I do my query. Any suggestions as to what to do here?










share|improve this question
























  • 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
















1














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:



enter image description here



So I went into the console and created an index:



enter image description here



And I keep getting that same error when I do my query. Any suggestions as to what to do here?










share|improve this question
























  • 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














1












1








1







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:



enter image description here



So I went into the console and created an index:



enter image description here



And I keep getting that same error when I do my query. Any suggestions as to what to do here?










share|improve this question















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:



enter image description here



So I went into the console and created an index:



enter image description here



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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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












2 Answers
2






active

oldest

votes


















1














If you're using array-contains to search a field, it looks like you need to add an Array Contains type index to it:



enter image description here



Notice that you have an option for that. It looks like what you did instead was make memberIds an Ascending type field index.






share|improve this answer





















  • 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



















0














For anyone interested, the correct index to prevent the index error for this query is:



arrayField: arrayContains
updatedAt: descending






share|improve this answer





















    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
    });


    }
    });














    draft saved

    draft discarded


















    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









    1














    If you're using array-contains to search a field, it looks like you need to add an Array Contains type index to it:



    enter image description here



    Notice that you have an option for that. It looks like what you did instead was make memberIds an Ascending type field index.






    share|improve this answer





















    • 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
















    1














    If you're using array-contains to search a field, it looks like you need to add an Array Contains type index to it:



    enter image description here



    Notice that you have an option for that. It looks like what you did instead was make memberIds an Ascending type field index.






    share|improve this answer





















    • 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














    1












    1








    1






    If you're using array-contains to search a field, it looks like you need to add an Array Contains type index to it:



    enter image description here



    Notice that you have an option for that. It looks like what you did instead was make memberIds an Ascending type field index.






    share|improve this answer












    If you're using array-contains to search a field, it looks like you need to add an Array Contains type index to it:



    enter image description here



    Notice that you have an option for that. It looks like what you did instead was make memberIds an Ascending type field index.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    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


















    • 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













    0














    For anyone interested, the correct index to prevent the index error for this query is:



    arrayField: arrayContains
    updatedAt: descending






    share|improve this answer


























      0














      For anyone interested, the correct index to prevent the index error for this query is:



      arrayField: arrayContains
      updatedAt: descending






      share|improve this answer
























        0












        0








        0






        For anyone interested, the correct index to prevent the index error for this query is:



        arrayField: arrayContains
        updatedAt: descending






        share|improve this answer












        For anyone interested, the correct index to prevent the index error for this query is:



        arrayField: arrayContains
        updatedAt: descending







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 21 at 17:37









        Zack Shapiro

        1,08183983




        1,08183983






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            404 Error Contact Form 7 ajax form submitting

            How to know if a Active Directory user can login interactively

            TypeError: fit_transform() missing 1 required positional argument: 'X'