Single index for different sources

I have two kind of docs there fore when indexing the sources are different. Seems some fields from one type of docs are not indexed.
Do I need to add empty fields to make equal(uniform) source from different source.

 "id" = "/userfile1",
 "age" = "100"

  "id" = "/dir/file2",
  "name" = "bob"

problem: now the field "age" is not indexed.

should I do somthing like this ?

if(doc.get("age") == null)

Or should I maintain two indixes?

ES will create a index map based on the first document it indexes (and therefore creates the index), so the fields it stores will be based on that first insert. So based on which every doc type you send first, it will only have those fields indexed. To overcome this, what you need to do is create an index template to predefine all the expected fields and how they should be stored.

If you have dynamic mapping enabled it will still accept the second doc. However as @crickes mentions, you are better of defining a mapping ahead of time.

Thanks @crickes and @warkolm for your answers. I just read about types (document types) and thought of indexing them as different types. (real documents are bit complex than shown in the example).
Should I go ahead and index as different types ? or should I create index template?

Don't use different types, see the breaking changes in 2.0 for examples of why they are not a good idea.