Rename an index
Solution
Use the Update
function:
ObjectV(ref: RefV(id = "all_of_the_people", collection = RefV(id = "indexes")),ts: LongV(1632032537300000),active: BooleanV(True),serialized: BooleanV(True),name: StringV(all_of_the_people),source: RefV(id = "People", collection = RefV(id = "collections")),values: Arr(ObjectV(field: Arr(StringV(data), StringV(first))), ObjectV(field: Arr(StringV(data), StringV(last))), ObjectV(field: Arr(StringV(ref)))),partitions: LongV(8))
map[active:true name:all_of_the_people partitions:8 ref:{all_of_the_people 0xc0000924b0 0xc0000924b0 <nil>} serialized:true source:{People 0xc0000925a0 0xc0000925a0 <nil>} ts:1631911524480000 values:[map[field:[data first]] map[field:[data last]] map[field:[ref]]]]
{ref: ref(id = "all_of_the_people", collection = ref(id = "indexes")), ts: 1632028348930000, active: true, serialized: true, name: "all_of_the_people", source: ref(id = "People", collection = ref(id = "collections")), values: [{field: ["data", "first"]}, {field: ["data", "last"]}, {field: ["ref"]}], partitions: 8}
{
ref: Index("all_of_the_people"),
ts: 1631909688640000,
active: true,
serialized: true,
name: 'all_of_the_people',
source: Collection("People"),
values: [
{ field: [ 'data', 'first' ] },
{ field: [ 'data', 'last' ] },
{ field: [ 'ref' ] }
],
partitions: 8
}
{'ref': Ref(id=all_of_the_people, collection=Ref(id=indexes)), 'ts': 1631911056110000, 'active': True, 'serialized': True, 'name': 'all_of_the_people', 'source': Ref(id=People, collection=Ref(id=collections)), 'values': [{'field': ['data', 'first']}, {'field': ['data', 'last']}, {'field': ['ref']}], 'partitions': 8}
{
ref: Index("all_of_the_people"),
ts: 1631835755950000,
active: true,
serialized: true,
name: 'all_of_the_people',
source: Collection("People"),
values: [
{ field: [ 'data', 'first' ] },
{ field: [ 'data', 'last' ] },
{ field: [ 'ref' ] }
],
partitions: 8
}
Discussion
You can rename an index,
add metadata, or change
the unique
field. However, you cannot change an index’s terms
or
values
definitions after the index has been created.
If you need to modify an index’s terms
or values
definition, you
should create a new index with the new definition, then rename the old
index out of the way, and rename the new index to use the original name
of the old index.
If you change unique
to true
, any existing duplicate items in the
index are not automatically removed.
Is this article helpful?
Tell Fauna how the article can be improved:
Visit Fauna's forums
or email docs@fauna.com
Thank you for your feedback!