Get an index document

Problem

You need to retrieve the document that describes an index from the current database.

Solution

Use the Get function:

try
{
    Value result = await client.Query(
        Get(Index("all_people"))
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
ObjectV(ref: RefV(id = "all_people", collection = RefV(id = "indexes")),ts: LongV(1632032492710000),active: BooleanV(True),serialized: BooleanV(True),name: StringV(all_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))
result, err := client.Query(
	f.Get(f.Index("all_people")))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
map[active:true name:all_people partitions:8 ref:{all_people 0xc0000924b0 0xc0000924b0 <nil>} serialized:true source:{People 0xc0000925a0 0xc0000925a0 <nil>} ts:1631912050530000 values:[map[field:[data first]] map[field:[data last]] map[field:[ref]]]]
System.out.println(
    client.query(
        Get(Index("all_people"))
    ).get());
{ref: ref(id = "all_people", collection = ref(id = "indexes")), ts: 1632028043350000, active: true, serialized: true, name: "all_people", source: ref(id = "People", collection = ref(id = "collections")), values: [{field: ["data", "first"]}, {field: ["data", "last"]}, {field: ["ref"]}], partitions: 8}
client.query(
  q.Get(q.Index('all_people'))
)
.then((ret) => console.log(ret))
.catch((err) => console.error('Error: %s', err))
{
  ref: Index("all_people"),
  ts: 1631909326360000,
  active: true,
  serialized: true,
  name: 'all_people',
  source: Collection("People"),
  values: [
    { field: [ 'data', 'first' ] },
    { field: [ 'data', 'last' ] },
    { field: [ 'ref' ] }
  ],
  partitions: 8
}
result = client.query(
  q.get(q.index("all_people"))
)
print(result)
{'ref': Ref(id=all_people, collection=Ref(id=indexes)), 'ts': 1631911190460000, 'active': True, 'serialized': True, 'name': 'all_people', 'source': Ref(id=People, collection=Ref(id=collections)), 'values': [{'field': ['data', 'first']}, {'field': ['data', 'last']}, {'field': ['ref']}], 'partitions': 8}
try {
  println(Await.result(
    client.query(
      Get(Index("all_people"))
    ),
    5.seconds
  ))
} catch {
  case unknown: Throwable => println("Error: " + unknown.getMessage())
}
{name: "all_people", source: ref(id = "People", collection = ref(id = "collections")), ts: 1632030660960000, ref: ref(id = "all_people", collection = ref(id = "indexes")), values: [{field: ["data", "last"]}, {field: ["data", "first"]}, {field: ["ref"]}], partitions: 8, serialized: true, active: true}
Get(Index("all_people"))
{
  ref: Index("all_people"),
  ts: 1631835750270000,
  active: true,
  serialized: true,
  name: 'all_people',
  source: Collection("People"),
  values: [
    { field: [ 'data', 'first' ] },
    { field: [ 'data', 'last' ] },
    { field: [ 'ref' ] }
  ],
  partitions: 8
}

More information

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve!
Visit Fauna's Discourse forums or email docs@fauna.com

Thank you for your feedback!