[ci skip] reproduce bug in (failing) test
@@ -318,9 +318,41 @@ func testDistributed(t *testing.T, dirName string, batch bool) {
assert.Equal(t, map[string]interface{}{
"other_property": "a-value-inserted-through-merge",
"description": previousMap["description"],
+ "date_property": previousMap["date_property"],
}, res.Object().Properties)
})
+ // This test prevents a regression on
+ // https://github.com/semi-technologies/weaviate/issues/1775
+ t.Run("query items by date filter", func(t *testing.T) {
+ count := len(data) / 2 // try to match half the data objects present
+ cutoff := time.Unix(0, 0).Add(time.Duration(count) * time.Hour).
+ Format(time.RFC3339)
+ node := nodes[rand.Intn(len(nodes))]
+ res, err := node.repo.ClassSearch(context.Background(), traverser.GetParams{
+ Filters: &filters.LocalFilter{
+ Root: &filters.Clause{
+ Operator: filters.OperatorLessThan,
+ On: &filters.Path{
+ Class: "Distributed",
+ Property: schema.PropertyName("date_property"),
+ },
+ Value: &filters.Value{
+ Value: cutoff,
+ Type: schema.DataTypeDate,
+ },
+ },
+ },
+ ClassName: "Distributed",
+ Pagination: &filters.Pagination{
+ Limit: len(data),
+ },
+ })
+
+ require.Nil(t, err)
+ assert.Len(t, res, count)
+ })
+
t.Run("delete a third of the data from random nodes", func(t *testing.T) {
for i, obj := range data {
if i%3 != 0 {
@@ -550,6 +582,10 @@ func class() *models.Class {
Name: "other_property",
DataType: []string{string(schema.DataTypeText)},
},
+ {
+ Name: "date_property",
+ DataType: []string{string(schema.DataTypeDate)},
+ },
},
}
}
@@ -588,11 +624,15 @@ func exampleData(size int) []*models.Object {
for i := range vec {
vec[i] = rand.Float32()
}
+
+ timestamp := time.Unix(0, 0).Add(time.Duration(i) * time.Hour).Format(time.RFC3339)
+
out[i] = &models.Object{
Class: "Distributed",
ID: strfmt.UUID(uuid.New().String()),
Properties: map[string]interface{}{
"description": fmt.Sprintf("object-%d", i),
+ "date_property": timestamp,
},
Vector: vec,
}
