I can't get ALL documents

Hello, I have a index. I am querying something specific by email. There is more than one document related to this e-mail, but only one of them returns when I query. How can I retrieve all documents linked to the same email with a filter like email?

try {
    const list = await authClient(token)
      .query(q.Get(q.Match(q.Index('list_by_creator_id'), uid)))
      .catch((err) => console.error('Error: %s', err));

    res.status(200).json(list.data);
  } catch (e) {
    res.status(500).json({ error: e.message });
  }

Index({
  name: "list_by_creator_id",
  unique: true,
  serialized: true,
  source: Collection("UserList"),
  terms: [{ field: ["data", "creator_id"], transform: "casefold" }]
})

Thanks.

Hello ! Please provide the definition of the Index and the Collection's data, it might help answering :slight_smile:

But normally, just querying something like :

Index({
  name: 'myIndex',
  sources: Collection('myCollection'),
  terms: [{ field: ['data', 'email'] }]
  ...
})

Should return all documents of myCollection that have data.email === 'foo@bar.com'

Please include the query you are trying to use as well. It sounds like you might be using Get() instead of Paginate(), but it’s hard to tell without the index definition and query.

@summer @n44ps I edited my question

Ok so you should do your query with Paginate instead of one Get :

const list = await authClient(token)
      .query(
        q.Map(
           q.Paginate(q.Match(q.Index('list_by_creator_id'), uid)),
           x => q.Get(x)
        )
      )
      .catch((err) => console.error('Error: %s', err));
1 Like