Ordering of results in `anyofterms` query

How does one order the results of a anyofterms based query?

The expectation is that the most relevant matches would be at the top of the result set, but this is not the case.

Example: Try the following on https://docs.dgraph.io/query-language/#term-matching

{
  me(func: anyofterms([email protected], "Judith Jones"), first: 10) {
    [email protected]
  }
}

This gives the following result set:

{
  "data": {
    "me": [
      {
        "[email protected]": "Una Brandon-Jones"
      },
      {
        "[email protected]": "Sasha Frere-Jones"
      },
      {
        "[email protected]": "Judith Jones"
      },
      {
        "[email protected]": "Damon Jones"
      },
      {
        "[email protected]": "Cheyenne Jones"
      },
      {
        "[email protected]": "Emily Jones"
      },
      {
        "[email protected]": "Sarah Jones"
      },
      {
        "[email protected]": "Chester Jones III"
      },
      {
        "[email protected]": "Ike Jones"
      },
      {
        "[email protected]": "Richard T. Jones"
      }
    ]
  }
}

Clearly “Judith Jones” is the best match and should be at the top.

Is there a way to get access to the score from the underlying bleve engine? That way we would be able to order the results.

If you don’t use orderasc or something. It will be ordered by UID. But anyway, this feels like a feature request. “order by best match”.

I don’t think so. There’s no feature like that (score or something). It also feels like a feature request. But I think there is one in that matter and it is already prioritized.

1 Like