1

Can anyone tell me is there a way to query nested field with index support. I created nested index like: r.table('comments').indexCreate('authorName', r.row("author")("name")).run(conn, callback) but I can't see any ways to query all comments which have specified author name - documentations says that getAll command takes number, string, bool, pseudotype, or array and filter command does not currently have an optimizer for indexes

B. Orlov
  • 23
  • 1
  • 2

1 Answers1

1

I've just tried creating a nested r.row("author")("name") secondary index named "authorName" for a table with the following rows:

[
  {
    "author": {
      "name":  "Lennon"
    },
    "text":  "c1",
    "id":  "4f66dcac-be74-49f2-b8dc-5fc352f4f928"
  },

  {
    "author": {
      "name":  "Cobain"
    },
    "text":  "c2",
    "id":  "82936ae0-bc4d-435b-b19a-6786339da232"
  }
]

It seems that

r.table('comments').getAll("Cobain", {index: "authorName"}).run(conn, callback)

is working and returns

  {
    "author": {
      "name":  "Cobain"
    },
    "text":  "c2",
    "id":  "82936ae0-bc4d-435b-b19a-6786339da232"
  }
Kludge
  • 2,653
  • 4
  • 20
  • 42
  • Thanks! I was thinking there are might be something like query object in MongoDB but now I realized that I need to manage all index names for nested object by myself (to avoid names duplication) – B. Orlov Jan 26 '16 at 11:07