Couchbase Lite: reading document vs querying data

I’m switching an Android project to using Couchbase Lite, and I’m confused with ways for fetching the data from the database.
I have a document, which contains only one property:

Map<String, Object> properties = new HashMap<String, Object>();
properties.put("data_key", json);
Document document = database.getDocument("data_doc_id");
document.putProperties(properties);

The next my step is getting the stored data from the database. I found two ways:

  1. The first approach is reading the document

     Document doc = database.getDocument("data_doc_id");
     String json = (String) doc.getProperty("data_key");
    
  2. The second one is quering

     View view = database.getView("data_json");
     view.setMap(new Mapper() {
         @Override
         public void map(Map<String, Object> document, Emitter emitter) {
             if ("data_doc_id".equals(document.get("_id")) {
                 String json = (String) doc.getProperty("data_key");
                 emitter.emit("data_key", json);
             }
         }
     }, "1.0");
     QueryEnumerator queryEnumerator = view.createQuery().run();
     String dataJson = "";
     for (QueryRow queryRow : run) {
         if ("data_key".equals(queryRow.getKey()) {
             json = (String) queryRow.getValue();        
         }    
     }
    

Is it okay to use the first approach to get the stored JSON?
For what cases the second approach should be used? It has far more code than the first one, maybe it has something to do with caching or/and speed/performance? What are the pros and cons of this approach?

Queries let you get data from lots of documents, possibly filtered by some property. For example, if your documents were airline flights, you could make a view that indexes every flight by arrival time, and query that to find all the flights that arrive between 6pm and 7pm.

Is it okay to use the first approach to get the stored JSON?

Yes, that’s exactly how you read a document if you know its ID.

For what cases the second approach should be used?

To be honest, your second example doesn’t make any sense. There’s no reason to create a view that only indexes data from a single document.

We have quite a bit of documentation on views and queries. Take a look at the principles and some of the examples given there.