FullTextScore not working with Cosmos DB (NoSQL)

Rioghan Cunniffe 0 Reputation points
2025-04-18T15:11:42.4733333+00:00

I’m using Cosmos DB with both Full-Text & Hybrid Search for NoSQL API and Vector Search for NoSQL API (both enabled before container creation). I’ve set up the appropriate indexing policy with full-text and vector indexes.

Here are three queries I’m testing:

This full-text filter query works fine:

SELECT TOP 10 * FROM c WHERE FullTextContains(c.description, 'blah blah blah') 

This vector-only query also works (I'm calling this from a function app where im getting the embeddings etc)

SELECT TOP 10 VALUE c.reportTitle
FROM c
ORDER BY VectorDistance(c.embedding, @embedding)

This fails with an error:

SELECT TOP 10 VALUE c.description
FROM c
ORDER BY RANK FullTextScore(c.description, ['allocation'])

Error message:

payload must exist nested within the outer payload field

Expected Behaviour:

According to the docs and my understanding, I should be able to use FullTextScore in combination with ORDER BY RANK for scoring. My end goal is to support hybrid search, combining both VectorDistance and FullTextScore (this also isnt working but one step at a time)


Current Setup:

My indexing policy includes:

{
  "indexingMode": "consistent",
  "automatic": true,
  "includedPaths": [{ "path": "/*" }],
  "excludedPaths": [
    { "path": "/\"_etag\"/?" },
    { "path": "/embedding/*" }
  ],
  "fullTextIndexes": [
    { "path": "/title" },
    { "path": "/description" },
    { "path": "/menu" },
    { "path": "/subMenu" }
  ],
  "vectorIndexes": [
    {
      "path": "/embedding",
      "type": "diskANN",
      "quantizationByteSize": 96,
      "indexingSearchListSize": 100
    }
  ]
}

Why does FullTextScore throw this payload error?
i get this erro both by the sqk and directly inside azure when i click "new query"

Would appreciate any help! I’m trying to combine full-text and vector search in a hybrid scoring model but am blocked here.

Thanks!

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,843 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sai Raghunadh M 3,155 Reputation points Microsoft External Staff
    2025-04-18T17:57:51.0733333+00:00

    Hi @ Rioghan Cunniffe

    As per my understanding, it seems like the issue with the FullTextScore function throwing a "payload must exist nested within the outer payload field" error might be related to the syntax or the way the query is structured. Based on the documentation, the FullTextScore function can only be used in an ORDER BY RANK clause and cannot be part of a projection (e.g., SELECT VALUE FullTextScore(...) is invalid).

    To resolve this, you might need to adjust your query to remove the VALUE keyword, as you mentioned in your follow-up. Here's an example of how the query could look:

    SELECT TOP 10 c.description
    FROM c
    ORDER BY RANK FullTextScore(c.description, ['allocation'])
    

    This aligns with the expected usage of FullTextScore as described in the documentation. Additionally, ensure that your indexing policy includes the necessary full-text indexes for the properties you're querying.

    If you're planning to combine VectorDistance and FullTextScore for hybrid search, you might need to carefully structure your query to ensure compatibility with both scoring functions.

    please go through this documentation that might helps you:

    https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/query/fulltextscore

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.