Create new index at runtime: How will the indexes for old objects be created?

Suppose I have docs like this :
{
_id:“doc_id”,
name:“some_name”,
phone_number:"+12…"
}

I have created a index on _id and inserted three docs with different data.
Now later as a requirement we need to add new index on phone_number. As per the tutorial docs it can be done by creating an insert transaction which adds indexs along with the main docs.

But what about the index for the three docs already instered, without indexes ?
How will they index ?
Do I need to design a mechanism, where it reads the range of all old docs and then create indexes on them ? Or is there any other automatic foundation db thing I missing in here.

Do I need to design a mechanism, where it reads the range of all old docs and then create indexes on them ?

  1. Are you talking about the fdb core or about some layers on top of it, ex. the Document Layer or Record Layer? If so, you should ask you question in Using Layers - FoundationDB , not here

  2. If you are asking about the fdb core, it does not have indices. They can be implemented as related KV-pairs.

  3. Foundationdb does not have any internal mechanisms for post-processing existing data out of box, including inserting the related KV-pairs. You should do it at the application level.

1 Like

No I was asking the question general how to use FDB for the use case.