Relation index returns no results

Working on a project related to this previous post Schema tips/best practices (Pinterest type app) , and I have just hit a wall it seems. I have a relations between type Board and Idea which I call “Board_Ideas”:


I have created several documents in the relation now via a UDF:

But trying to query the indexes created for the relation returns empty:

Any clue what’s going on? Is this a bug?

Can you show us the output of Get(Index("board_ideas_by_idea"))?

Get(Index("board_ideas_by_idea"))

{
  ref: Index("board_ideas_by_idea"),
  ts: 1620931186190000,
  active: true,
  serialized: true,
  name: "board_ideas_by_idea",
  source: Collection("board_ideas"),
  data: {
    gql: {
      ts: Time("2021-05-13T18:39:45.897395Z")
    }
  },
  values: [
    {
      field: ["data", "boardID"]
    }
  ],
  terms: [
    {
      field: ["data", "ideaID"]
    }
  ],
  unique: false,
  partitions: 1
}

Is the result I get.

The problem is that your documents contain references for the boardID and ideaID fields, but your query only includes the document ID portion of the reference.

Use this query instead:

Paginate(
  Match(
    Index("board_ideas_by_idea"),
    Ref(Collection("ideas"), "298501659868237013")
  )
)

Similarly, in the dashboard, you will want to change data.ideaID type from String to FQL using the drop down. Then you can type in the Ref like Ewan shows in the full query.

view from my dashboard:
image

1 Like

Thanks for your feedback. That was the issue!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.