I'm using a non-edge GraphQL endpoint to leverage keyword search and faceting in my content search queries. This means that I'm using the Sitecore.Services.GraphQL.Content.Queries.SearchQuery
class instead of the Sitecore.Services.GraphQL.EdgeSchema.Queries.SearchQuery
that comes with the Edge schema.
My query looks like this:
query( $language: String = "en"
$keyword: String!
$first: Int = 10
$after: String
) {
search(
rootItem: "/sitecore/content/Client/MainSite/Home",
keyword: $keyword,
first: $first,
after: $after,
fieldsEqual:[
{name:"_haslayout", value:"true"},
{name:"_latestversion", value:"true"},
{name:"_language", value: $language}
],
) {
results {
totalCount
pageInfo {
hasNextPage
hasPreviousPage
}
items {
score
item {
displayName
template {
name
}
}
}
}
}
}
I get results back, but the relevancy is unclear. The biggest thing that I notice is that the score
field is the same for every result item.
{
"data": {
"search": {
"results": {
"totalCount": 3,
"pageInfo": {
"hasNextPage": false,
"hasPreviousPage": false
},
"items": [
{
"score": 4.8768038749694824,
"item": {
"displayName": "Health benefits of coffee",
"template": {
"name": "Article"
}
}
},
{
"score": 4.8768038749694824,
"item": {
"displayName": "Dr. Pepper",
"template": {
"name": "Person"
}
}
},
{
"score": 4.8768038749694824,
"item": {
"displayName": "Nespresso",
"template": {
"name": "Product"
}
}
}
]
}
}
}
}
Has anyone run into this and figured out how to correct it?
score
should never be the same across all result documents.