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

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

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

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

Hi David,

Can you please help and advise on the above issue.

Thanks in advance for your support

Regards
Asim

Please format your code using </> icon as explained in this guide. It will make your post more readable.

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

Will be easier to reproduce and understand.

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"
				        }
				    }
				}
				
			    }

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

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

		//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`

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

I can't reproduce this. Read again this: About the Elasticsearch category

And provide a pure elasticsearch script like:

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

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