Adjust to include leading zero in front of date regex.
This commit is contained in:
parent
c6ac0bc6af
commit
265be4e09d
|
@ -77,9 +77,9 @@ func (a *Elasticsearch) Connect() error {
|
|||
year := strconv.Itoa(time.Now().Year())
|
||||
a.IndexName = strings.Replace(a.IndexName, "%Y", year, -1)
|
||||
a.IndexName = strings.Replace(a.IndexName, "%y", year[len(year)-2:], -1)
|
||||
a.IndexName = strings.Replace(a.IndexName, "%m", strconv.Itoa(int(time.Now().Month())), -1)
|
||||
a.IndexName = strings.Replace(a.IndexName, "%d", strconv.Itoa(time.Now().Day()), -1)
|
||||
a.IndexName = strings.Replace(a.IndexName, "%H", strconv.Itoa(time.Now().Hour()), -1)
|
||||
a.IndexName = strings.Replace(a.IndexName, "%m", fmt.Sprintf("%0.2d", time.Now().Month()), -1)
|
||||
a.IndexName = strings.Replace(a.IndexName, "%d", fmt.Sprintf("%0.2d", time.Now().Day()), -1)
|
||||
a.IndexName = strings.Replace(a.IndexName, "%H", fmt.Sprintf("%0.2d", time.Now().Hour()), -1)
|
||||
}
|
||||
|
||||
exists, errExists := a.Client.IndexExists(a.IndexName).Do()
|
||||
|
|
|
@ -18,7 +18,7 @@ func TestConnectAndWrite(t *testing.T) {
|
|||
|
||||
e := &Elasticsearch{
|
||||
ServerHost: serverhost,
|
||||
IndexName: "littletest",
|
||||
IndexName: "littletest-%Y%m%d",
|
||||
NumberOfShards: 1,
|
||||
NumberOfReplicas: 0,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue