rnewson / couchdb-lucene

Enables full-text searching of CouchDB documents using Lucene
Apache License 2.0
769 stars 145 forks source link

Age time calculate results are not updated #257

Closed wonderfuljamesjin closed 7 years ago

wonderfuljamesjin commented 7 years ago

Hi

I need calculate the time age days based on the couchdb document : doc.lastupdate with current day, I defined the couchdb map view as following, I did not know why the results not update/refresh everyday? like the doc.lastupdate =2017-08-16 23:15:1, but today it still see the results as 0 age day? only after I change the view and save it, the result can be taken effect as expected, I know there is a setting in couched stale=update_after, but it is not working

function(doc) {
    if (doc.type) {
       new_date = doc.lastupdate;
      var date_arr = new_date.split(" ");
      var date_aar2 = date_arr[0];
      date_aar2 = new Date(date_aar2.replace(/-/g, "/"));
      date_aar1 = new Date();
      var days = date_aar1.getTime() - date_aar2.getTime();
      var age = parseInt(days / (1000 * 60 * 60 * 24));
      emit(date_aar2,age);
       }
   }
wonderfuljamesjin commented 7 years ago

Hi @rnewson please help take a look above issue, thank you

wonderfuljamesjin commented 7 years ago

Thanks, I figured out how to fix the issue

rnewson commented 7 years ago

You figured out that the function is only called once until the document is updated? good. :)