1

I'm running this query:

Paginate(
    Match(
        Index("chatMemberships_by_user"), 
        Ref(Collection('users'), "307731780020994112")
    )
)

On this index:

{
  name: "chatMemberships_by_user",
  serialized: true,
  source: "chats",
  terms: [
    {
      field: ["data", "user"]
    }
  ],
  values: [
    {
      field: ["data", "lastActive"]
    },
    {
      field: ["data", "chat"]
    },
    {
      field: ["ref"]
    }
  ]
}

The chatMemberships collection contains these two documents:

{
  "ref": Ref(Collection("chatMemberships"), "307917574923878464"),
  "ts": 1629911932790000,
  "data": {
    "user": Ref(Collection("users"), "307731780020994112"),
    "chat": Ref(Collection("chats"), "307917574915489856"),
    "createdAt": Time("2021-08-25T17:18:52.711023Z"),
    "lastActive": Time("2021-08-25T17:18:52.711023Z")
  }
},
{
  "ref": Ref(Collection("chatMemberships"), "307917574923879488"),
  "ts": 1629911932790000,
  "data": {
    "user": Ref(Collection("users"), "307828268328812611"),
    "chat": Ref(Collection("chats"), "307917574915489856"),
    "createdAt": Time("2021-08-25T17:18:52.711023Z"),
    "lastActive": Time("2021-08-25T17:18:52.711023Z")
  }
}

After running the query, the result I get is an empty array instead of an array containing the matching chatMembership document (should be the first one in the screenshot).

{ data: [] }

Any idea on what's causing this? Am I crazy or is this a bug? Thanks!

2
  • 1
    you are indexing the wrong collection, your index source is chats but the collection you are referring is chatMemberships Commented Aug 25, 2021 at 19:33
  • Omg, spent hours on this today! Thank you Marrony! Commented Aug 26, 2021 at 1:48

1 Answer 1

1

The problem was that I was referencing the wrong source collection in the index. It should have been “chatMemberships” instead of “chats”.

Sign up to request clarification or add additional context in comments.

1 Comment

Hi Mike. You can and should mark your answer as the solution if your issue is resolved. That will signal everyone in StackOverflow that this question does not need any more attention.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.