# Having problem retrieving the data from ES for the 1st of every month

**URL:** https://discuss.elastic.co/t/having-problem-retrieving-the-data-from-es-for-the-1st-of-every-month/68843
**Category:** Elasticsearch
**Created:** [December 13, 2016, 9:42am UTC](https://discuss.elastic.co/t/having-problem-retrieving-the-data-from-es-for-the-1st-of-every-month/68843 "2016-12-13T09:42:26Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Asim611](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@Asim611](https://discuss.elastic.co/u/Asim611)
#### Post date: [December 13, 2016, 9:42am UTC](https://discuss.elastic.co/t/having-problem-retrieving-the-data-from-es-for-the-1st-of-every-month/68843/1 "2016-12-13T09:42:26Z")

</div>

Hi Team,

We have develop a sample visibility tool using elastic search(ES) where our front end is jquery,able to retrieve data from ES for all the data range except for 1st of every month.  
Though there is no index created for 2nd of December but able see all the data which was uploaded on 1st of December but for 1st December its retrieving zero records.  
please advise on the above issue.

Thanks in advance for your support.

Regards  
Asim

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [December 13, 2016, 10:32am UTC](https://discuss.elastic.co/t/having-problem-retrieving-the-data-from-es-for-the-1st-of-every-month/68843/2 "2016-12-13T10:32:27Z")

</div>

You need to give more info.  
Like docs, mapping and queries

---

<div class="post-metadata">

### Author: ![Asim611](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@Asim611](https://discuss.elastic.co/u/Asim611)
#### Post date: [December 13, 2016, 11:33am UTC](https://discuss.elastic.co/t/having-problem-retrieving-the-data-from-es-for-the-1st-of-every-month/68843/3 "2016-12-13T11:33:35Z")

</div>

Hi David,

Below is the data uploaded on server for 1st December 2016  
{  
"took" : 1,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 17,  
"max\_score" : 1.0,  
"hits" : [ {  
"\_index" : "20161201",  
"\_type" : "09",  
"\_id" : "-3398698314401205853",  
"\_score" : 1.0,  
"\_source" : {  
"sourceID" : "00\n995419AS2",  
"receiverID" : "TESTQA",  
"partnerName" : "NA",  
"transType" : "NA",  
"FilePath" : "D:\ARCHIVE\comm\201612\01\Recv\file\_20161201\_0920011\_SIAPPQALV2node21585311cbb11191089.EDI",  
"postDate" : "2016-12-01T18:33:12-0600",  
"\_REF" : {  
"OriginalRef" : "NA",  
"AlternateRef" : "NA"  
},  
"\_CntrlNumbers" : {  
"ISACntrl" : "00000495\n",  
"GSCntrl" : "495\n",  
"STCntrl" : "495"  
},  
"message" :  
“parseddata” :

Query was to retrieve the data using Search by Date  
From Date: 2016-12-01T00:00:00.000Z  
To Date :2016-12-01T23:59:59.000Z

Currently there is no index created for 2nd December 2016 though there is no data in archive for the same but all the 17 records that got loaded on 1st December 2016 is retrieved for below query  
From Date: 2016-12-02T00:00:00.000Z  
To Date : 2016-12-02T23:59:59.000

Regards  
Asim

---

<div class="post-metadata">

### Author: ![Asim611](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@Asim611](https://discuss.elastic.co/u/Asim611)
#### Post date: [December 14, 2016, 4:44pm UTC](https://discuss.elastic.co/t/having-problem-retrieving-the-data-from-es-for-the-1st-of-every-month/68843/4 "2016-12-14T16:44:13Z")

</div>

Hi David,

Can you please help and advise on the above issue.

Thanks in advance for your support

Regards  
Asim

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [December 14, 2016, 11:45pm UTC](https://discuss.elastic.co/t/having-problem-retrieving-the-data-from-es-for-the-1st-of-every-month/68843/5 "2016-12-14T23:45:26Z")

</div>

Please format your code using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will make your post more readable.

Can you reproduce it with a full script as described here:

> **[Elasticsearch](https://discuss.elastic.co/c/elasticsearch)**
>
> Any questions related to Elasticsearch, including specific features, language clients and plugins.

Will be easier to reproduce and understand.

---

<div class="post-metadata">

### Author: ![Asim611](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@Asim611](https://discuss.elastic.co/u/Asim611)
#### Post date: [December 15, 2016, 6:22am UTC](https://discuss.elastic.co/t/having-problem-retrieving-the-data-from-es-for-the-1st-of-every-month/68843/6 "2016-12-15T06:22:40Z")

</div>

Hi David,

below is the UI code  
var isaid = $("#isaid").val();

```
 	    		var daterange = $("#daterange").val().split("-");
				console.log(daterange);
 	    		var from = daterange[0].replace(/\//g, '-').trim()+"T00:00:00.000Z";
		var to = daterange[1].replace(/\//g, '-').trim()+"T23:59:59.000Z";
				
 	    		
 	    		
 	    		var data = {"size":1000,"query":{
				    "range" : {
				        "postDate" : {
				            "gte": from,
				            "lte": to,
				            "format": "dateOptionalTime"
				        }
				    }
				}
				
			    }
```

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [December 15, 2016, 6:42am UTC](https://discuss.elastic.co/t/having-problem-retrieving-the-data-from-es-for-the-1st-of-every-month/68843/7 "2016-12-15T06:42:40Z")

</div>

Can you share please a full script I can use to reproduce your problem?

As it's explained in the thread I linked to.

---

<div class="post-metadata">

### Author: ![Asim611](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@Asim611](https://discuss.elastic.co/u/Asim611)
#### Post date: [December 15, 2016, 7:42am UTC](https://discuss.elastic.co/t/having-problem-retrieving-the-data-from-es-for-the-1st-of-every-month/68843/8 "2016-12-15T07:42:49Z")

</div>

```
		//date range search
		
		$("#dr_search").on("click",function(){
     	    		$("#dr_search").prop("value","Searching...");
     	    		
     	    		$("#data-tbody").html("");
					
					if(dataTableObj){
						dataTableObj.fnClearTable();
						dataTableObj.fnDestroy();
					}
					//console.log(dataTableObj);
     	    		var isaid = $("#isaid").val();
					
     	    		var daterange = $("#daterange").val().split("-");
					console.log(daterange);
     	    		var from = daterange[0].replace(/\//g, '-').trim()+"T00:00:00.000Z";
					//var from = '01/12/201600:00:00';
					console.log(from);
					alert(from);
     	    		var to = daterange[1].replace(/\//g, '-').trim()+"T23:59:59.000Z";
					//var to = '01/12/201623:59:59';
					console.log(to);
					alert(to);
					//var from = daterange[0].replace(/\//g, '-').trim()+"T00:00:00";
     	    		//var to = daterange[1].replace(/\//g, '-').trim()+"T23:59:59";
     	    		
     	    		//alert(from +" "+to);
     	    		var data = {"size":1000,"query":{
					    "range" : {
					        "postDate" : {
					            "gte": from,
					            "lte": to,
								//"format": "yyyy-MM-ddT00:00:00.000Z||yyyy-MM-ddT23:59:59.000Z"
					            "format": "dateOptionalTime"
					        }
					    }
					}
					
				    }
					alert(data);
					console.log(data);
					
			//var dburl = "http://localhost:9200/"+"_search";
			//var dburl = "http://10.138.17.18:9200/"+$("#partner_name").val()+"/"+$("#ttype").val()+"/_search";
			//var dburl = "http://10.138.17.18:9200/_search";
			var dburl = "http://10.20.64.159:9200/_search";
			
     	    		
     	    		console.log("DB URL being hit");
     	    		console.log(dburl);
     	    		
     	    		console.log("Data is being sent");
     	    		console.log(data);
     	    		
     	    		<!--if($("#ttype").val()!=""&&$("#partner_name").val()==""){alert("Please enter Partner Name"); return } -->
     	    		
     	    		$.ajax({
		            url: dburl,
		            type: 'post',
		            contentType: 'application/json; charset=UTF-8',
		            dataType: "json",
		            crossDomain: true,
		            data: JSON.stringify(data),
		            success: function (data) {
		           
		            	alert(data.hits.hits.length+" Record found");
		            	for(var i=0;i<data.hits.hits.length;i++){
		            		var source = data.hits.hits[i]._source;
							var ref = source._REF;
							var cntrl = source._CntrlNumbers;
		            		var altRef = " ";
							if(ref.AlternateRef != "NA") {
								altRef = ref.AlternateRef;
							}
							var pDate = source.postDate;
							//pDate = pDate.replace("Z","");
							//pDate = pDate.replace("+0530","");
		            		$("#data-tbody").append("<tr>"+
									"<td>"+source.partnerName+"</td>"+
		     	    				"<td>"+source.sourceID+"</td>"+
									"<td>"+source.receiverID+"</td>"+
		     	    				"<td>"+source.transType+"</td>"+
		     	    				"<td>"+ref.OriginalRef+"</td>+"+
		     	    				"<td>"+altRef+"</td>+"+
		     	    				"<td>"+pDate+"</td>"+
		     	    				"<td><button type='button' class='btn btn-primary btn-sm openmodal' data-id="+i+">View file data</button><xmp style='display:none;' id="+i+">"+source.message+"</xmp></td>"+
		     	    				"<td id="+i+"filepath>"+source.FilePath+"</td>"+
		     	    			"</tr>");
		     	    		
		     	    		$(".openmodal").on("click",function(){
		     	    			var id = $(this).data("id");
		     	    			$("#myModalLabel").html($("#"+id+"filepath").html());
		     	    			$("#filedata").html($("#"+id).html());
			     	    		$('#myModal').modal();
			     	    	});
		     	    			
		     	    	}
		            	
		            	$('#mydata-table').trigger('update');
						//dataTableObj = $('#mydata-table').DataTable();
	     	    		dataTableObj = $('#mydata-table').dataTable({
                        "iDisplayLength": 5,
                        "aLengthMenu": [[5, 10, 25, 50, -1], [5, 10, 25, 50, "All"]]
                        });
						
	     	    		if($("#data-tbody").find("tr").length==0){alert("No Record found");}
		                
		                $("#dr_search").val("Search");
						
		            }
		        }).fail(function (error) {
		            console.log("Search Failed");
		            if($("#data-tbody").find("tr").length==0){alert("No Record found");}
		                
		                $("#dr_search").val("Search");
		        })
     	    		    	
     	    	});//date range search`Preformatted text`
```

---

<div class="post-metadata">

### Author: ![Asim611](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@Asim611](https://discuss.elastic.co/u/Asim611)
#### Post date: [December 15, 2016, 7:46am UTC](https://discuss.elastic.co/t/having-problem-retrieving-the-data-from-es-for-the-1st-of-every-month/68843/9 "2016-12-15T07:46:54Z")

</div>

Hi David,

Have pasted the date range code tried pasting complete UI code but it huge and it's get error for its size.

Thanks  
Asim

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [December 15, 2016, 9:10am UTC](https://discuss.elastic.co/t/having-problem-retrieving-the-data-from-es-for-the-1st-of-every-month/68843/10 "2016-12-15T09:10:25Z")

</div>

I can't reproduce this. Read again this: [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21)

And provide a pure elasticsearch script like:

```auto
DELETE index
PUT index/type/1
{
  "foo": "bar"
}
GET index/type/_search
{
  "query": {
    "match": {
      "foo": "bar"
    }
  }
}

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [January 12, 2017, 9:10am UTC](https://discuss.elastic.co/t/having-problem-retrieving-the-data-from-es-for-the-1st-of-every-month/68843/11 "2017-01-12T09:10:50Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
