Class DefaultAzureCosmosDBNoSqlFilterMapper

java.lang.Object
dev.langchain4j.rag.content.retriever.azure.cosmos.nosql.DefaultAzureCosmosDBNoSqlFilterMapper
All Implemented Interfaces:
AzureCosmosDBNoSqlFilterMapper

public class DefaultAzureCosmosDBNoSqlFilterMapper extends Object implements AzureCosmosDBNoSqlFilterMapper
Maps Filter objects to Azure Cosmos DB NoSQL filter strings. Supports standard comparison operators and full-text search functions.

A filter names the document property to compare through its metadata key. The key is rendered as the quoted property accessor, so the key category produces c["category"]. A dot separates path segments rather than forming part of a name, so metadata.category produces c["metadata"]["category"], and a property whose own name contains a dot cannot be addressed. Every other character is taken literally, including spaces, punctuation, and names that collide with a Cosmos DB reserved word.

A document is stored as id, embedding, text and metadata, with the metadata of a TextSegment nested under metadata. To filter on a metadata entry, prefix its name with metadata.: the key metadata.category matches the metadata entry named category, whereas the bare key category looks for a top-level property of that name and so matches nothing.

Keys and values are both escaped, so neither can end the quoted text it sits in and add query syntax of its own. A key that arrived from untrusted input and looks like a fragment of a query is therefore treated as an ordinary property name, and cannot alter the query structure. Whether it matches a document depends on the document's properties and the filter operator.

Comparison values support String, UUID (as a quoted string), Boolean, Byte, Short, Integer, Long, finite Float and Double, and exact BigInteger and BigDecimal instances (not subclasses). Unsupported types, null values, and non-finite numbers cause an IllegalArgumentException. This also applies to each element of an IsIn or IsNotIn filter.

  • Constructor Details

    • DefaultAzureCosmosDBNoSqlFilterMapper

      public DefaultAzureCosmosDBNoSqlFilterMapper()
  • Method Details