Query not giving results of new documents

Hi there,

I’m new to the forums. I’m sure this is an easy question, but I cannot find what I am doing wrong. I have a collection that I’ve filled with a couple thousand records. I can add new records to it; however, I cannot retrieve the new ones.

Here is how I created a record:

Create(Collection(“Child”), {
data: {
data: {
beneficiary_id: “1234”,
name: “Test”,
full_name: “Test”,
age: “5”,
date_of_birth: “1/11/2011”,
gender: “F”,
country: “Colombia”,
language_spoken: “Spanish”,
}
}
}
)

If I run the index called allChildren, it returns a bunch, but not all (even on the admin screen, it says results are limited to 100 for performance). So I ran it with a large size and it returns all, including the new children I created:

Map(
Paginate(Match(Index(“allChildren”)),
{
size: 10000
}
),
Lambda(“X”, Get(Var(“X”)))
)

Here is the weird thing. I created a new index to search for a child by name:

CreateIndex({
name: “children_by_name_shell”,
source: Collection(“Child”),
terms: [
{
field: [“data”, “name”]
}
]
})

If I run it on a child that prints out on the admin screen under allChildren index, it returns a record. But if I run it using the name of the new child, it returns an empty array, like it’s not found. But it’s clearly there when I query all and put in the large size (size: 10000). Is the index not searching all the records? Is there some limit?

Thanks in advance for any help!

Hi @abogdan and welcome.

To get the index children_by_name_shell working, you have to store documents that way:

Create(Collection("Child"), 
  {
    data: {
      beneficiary_id: "1234",
      name: "Test",
      full_name: "Test",
      age: "5",
      date_of_birth: "1/11/2011",
      gender: "F",
      country: "Colombia",
      language_spoken: "Spanish",
    }
  }
)

and not nesting data twice:

.......
  { data:
      { data:
.......

MAy you try to create a document as the one I posted above and see if the index children_by_name_shell works?
The query is like that:

Paginate(Match('children_by_name_shell', 'Test'))

Luigi

Wow - @Luigi_Servini. It works. I didn’t see that additional data nest. Thank you so much!