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(name@en, "Judith Jones"), first: 10) {
    name@en
  }
}

This gives the following result set:

{
  "data": {
    "me": [
      {
        "name@en": "Una Brandon-Jones"
      },
      {
        "name@en": "Sasha Frere-Jones"
      },
      {
        "name@en": "Judith Jones"
      },
      {
        "name@en": "Damon Jones"
      },
      {
        "name@en": "Cheyenne Jones"
      },
      {
        "name@en": "Emily Jones"
      },
      {
        "name@en": "Sarah Jones"
      },
      {
        "name@en": "Chester Jones III"
      },
      {
        "name@en": "Ike Jones"
      },
      {
        "name@en": "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