diff --git a/cluster.go b/cluster.go index 5eb4acc82..765ee7845 100644 --- a/cluster.go +++ b/cluster.go @@ -2918,6 +2918,10 @@ func (c *cluster) createIndexKeys(ctx context.Context, indexName string, keys .. return nil, ErrIndexNotFound } + if !idx.keys { + return nil, errors.Errorf("can't create index keys on unkeyed index %s", indexName) + } + // Split keys by partition. keysByPartition := make(map[int][]string, c.partitionN) for _, key := range keys { diff --git a/executor_test.go b/executor_test.go index 3d8cddd7f..29e843d6e 100644 --- a/executor_test.go +++ b/executor_test.go @@ -575,7 +575,7 @@ func TestExecutor_Execute_Set(t *testing.T) { }) t.Run("ErrInvalidColValueType", func(t *testing.T) { - if _, err := cmd.API.Query(context.Background(), &pilosa.QueryRequest{Index: "i", Query: `Set("foo", f=1)`}); err == nil || !hasCause(err, pilosa.ErrTranslatingKeyNotFound) || !strings.Contains(err.Error(), "unkeyed index") { + if _, err := cmd.API.Query(context.Background(), &pilosa.QueryRequest{Index: "i", Query: `Set("foo", f=1)`}); err == nil || !strings.Contains(err.Error(), "unkeyed index") { t.Fatalf("The error is: '%v'", err) } }) @@ -977,7 +977,7 @@ func TestExecutor_Execute_SetValue(t *testing.T) { }) t.Run("ColumnBSIGroupValue", func(t *testing.T) { - if _, err := c.GetNode(0).API.Query(context.Background(), &pilosa.QueryRequest{Index: "i", Query: `Set("bad_column", f=100)`}); err == nil || !hasCause(err, pilosa.ErrTranslatingKeyNotFound) || !strings.Contains(err.Error(), "unkeyed index") { + if _, err := c.GetNode(0).API.Query(context.Background(), &pilosa.QueryRequest{Index: "i", Query: `Set("bad_column", f=100)`}); err == nil || !strings.Contains(err.Error(), "unkeyed index") { t.Fatalf("unexpected error: %s", err) } })