In the How does the “similar” feature work? @samlittlefair mentioned that results are returned in order of relevance:
- Do results come back in any particular order?
Yes, most relevant first. We give more priority to RichText content, especially headings.
This doesn't appear consistent with the results I'm seeing: AFAICT the order of results is the same as when the similar
argument is not provided.
I've created a new content type, and added two articles (alpha
and beta
). I then duplicated both articles (alpha-duplicate
and beta-duplicate
), and queried them:
Query:
{
allTest_pages(first: 99) {
edges {
node {
_meta {
id
uid
}
}
}
}
}
Result:
{
"data": {
"allTest_pages": {
"edges": [
{
"node": {
"_meta": {
"id": "1",
"uid": "alpha"
}
}
},
{
"node": {
"_meta": {
"id": "2",
"uid": "beta"
}
}
},
{
"node": {
"_meta": {
"id": "3",
"uid": "alpha-duplicate"
}
}
},
{
"node": {
"_meta": {
"id": "4",
"uid": "beta-duplicate"
}
}
}
]
}
}
}
I then ran the query with the similar
argument:
Query:
{
allTest_pages(first: 99, similar: {documentId: "1", max: 9999}) {
edges {
node {
_meta {
id
uid
}
}
}
}
}
Result:
{
"data": {
"allTest_pages": {
"edges": [
{
"node": {
"_meta": {
"id": "2",
"uid": "beta"
}
}
},
{
"node": {
"_meta": {
"id": "3",
"uid": "alpha-duplicate"
}
}
},
{
"node": {
"_meta": {
"id": "4",
"uid": "beta-duplicate"
}
}
}
]
}
}
}
If the results were ordered by relevance, I would have expected to see alpha-duplicate
as the first item. Reducing the value of max
verifies that alpha-duplicate
is in fact the most relevant, as both beta
results disappear:
Query:
{
allTest_pages(first: 99, similar: {documentId: "1", max: 1}) {
edges {
node {
_meta {
id
uid
}
}
}
}
}
Result:
{
"data": {
"allTest_pages": {
"edges": [
{
"node": {
"_meta": {
"id": "3",
"uid": "alpha-duplicate"
}
}
},
]
}
}
}
Am I missing something? Is there a way to sort these correctly?