Hello, friend!
In step 1, you need to plan and build indexes first. Indexes can be created in many ways. Indexes are used to facilitate search. When the data volume is large, the number of indexes also determines the performance. Therefore, the first step of creating an index is to build your own index and plan the dimensions for creating the index.
In step 3, the indexwriter object is used to write the document object to the index library. In this process, the index is created and the index and document object are written to the index.
Hope this helps!