title: Couchbase Lite Java: Creating View & Query with Exact Keys
body: <p>I am trying to query base on my own custom view, but it did not turn out what I expected.</p>
  
  <p>I would like to query with keys example like ["2017", "5", "26"], <strong>endDateTime</strong> is the column in my Json Data which storing millisecond.</p>
  
  <p>I have emitted with <strong>List</strong> to store date.</p>
  
  <p>When I ran my query by today date (database do have data for the date that I am searching), I have debugged with breakpoint to check the List that stored the date in view and query both is identical.</p>
  
  <p>I can't find the reason why <strong>queryEnumerator</strong> return no row.</p>
  
  <p>Please help my issue, I have been tried many ways but still no luck.</p>
  
  <p>Appreciate for the help.</p>
  
  <pre><code>public View getViewTransactionByEndDate() {
      View view = this.getDatabase().getView("Transaction");
  
      if (view.getMap() == null) {
          view.setMap(new Mapper() {
              @Override
              public void map(Map&lt;String, Object&gt; document, Emitter emitter) {
                  if (document.get("type") != null) {
                      if (document.get("type").equals("Transaction")) {
                          Calendar dataCalendar = Calendar.getInstance(); 
  
                          /* due to too long the code, */ 
                          /* I have break it to 2 lines */
                          Long endDateTime = 
                          Long.parseLong(document.get("endDatetime"));
  
                          dataCalendar.setTimeInMillis(endDateTime);
  
                          List&lt;Object&gt; key = new ArrayList&lt;&gt;();
                          key.add(dataCalendar.get(Calendar.YEAR));
                          key.add(dataCalendar.get(Calendar.MONTH) + 1);
                          key.add(dataCalendar.get(Calendar.DAY_OF_MONTH));
  
                          HashMap&lt;String, Object&gt; value = new HashMap&lt;&gt;();
                          value.put("_id", document.get("_id"));
  
                          emitter.emit(key, value);
                      }
                  }
              }
         }, "1");
      }
  
      return view;
  }
  
  
  /* The query part */
  Query query = getViewTransactionByEndDate().createQuery();
  
  Calendar todayCalendar = Calendar.getInstance();
  todayCalendar.setTime(new Date());
  
  List&lt;Object&gt; key = new ArrayList&lt;&gt;();
  key.add(todayCalendar.get(Calendar.YEAR));
  key.add(todayCalendar.get(Calendar.MONTH) + 1);
  key.add(todayCalendar.get(Calendar.DAY_OF_MONTH));
  
  query.setKeys(key);
  
  QueryEnumerator queryEnumerator = query.run();
  </code></pre>