LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangChain
  • Universal
  • Hub
  • Node
  • Load
  • Serializable
  • Encoder Backed
  • File System
  • In Memory
LangChain Core
  • Agents
  • Caches
  • Base
  • Dispatch
  • Web
  • Manager
  • Promises
  • Chat History
  • Context
  • Base
  • Langsmith
  • Documents
  • Embeddings
  • Errors
  • Example Selectors
  • Indexing
  • Base
  • Chat Models
  • Llms
  • Profile
  • Load
  • Serializable
  • Memory
  • Messages
  • Tool
  • Output Parsers
  • Openai Functions
  • Openai Tools
  • Outputs
  • Prompt Values
  • Prompts
  • Retrievers
  • Document Compressors
  • Runnables
  • Graph
  • Singletons
  • Stores
  • Structured Query
  • Tools
  • Base
  • Console
  • Log Stream
  • Run Collector
  • Tracer Langchain
  • Stream
  • Async Caller
  • Chunk Array
  • Context
  • Env
  • Event Source Parse
  • Format
  • Function Calling
  • Hash
  • Json Patch
  • Json Schema
  • Math
  • Ssrf
  • Stream
  • Testing
  • Tiktoken
  • Types
  • Vectorstores
Text Splitters
MCP Adapters
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangChain
UniversalHubNodeLoadSerializableEncoder BackedFile SystemIn Memory
LangChain Core
AgentsCachesBaseDispatchWebManagerPromisesChat HistoryContextBaseLangsmithDocumentsEmbeddingsErrorsExample SelectorsIndexingBaseChat ModelsLlmsProfileLoadSerializableMemoryMessagesToolOutput ParsersOpenai FunctionsOpenai ToolsOutputsPrompt ValuesPromptsRetrieversDocument CompressorsRunnablesGraphSingletonsStoresStructured QueryToolsBaseConsoleLog StreamRun CollectorTracer LangchainStreamAsync CallerChunk ArrayContextEnvEvent Source ParseFormatFunction CallingHashJson PatchJson SchemaMathSsrfStreamTestingTiktokenTypesVectorstores
Text Splitters
MCP Adapters
Language
Theme
JavaScript@langchain/corestructured_query
Module●Since v1.0

structured_query

Copy
import { ... } from "@langchain/core/structured_query";

Functions

function
castValue→ string | number | boolean

Casts a value that might be string or number to actual string or number. Since LLM might return back an integer/float as a string, we need to cast it back to a number, as many vector databases can't handle number as string values as a comparator.

function
isBoolean→ boolean

Checks if the provided value is a boolean.

function
isFilterEmpty→ filter is undefined

Checks if a provided filter is empty. The filter can be a function, an object, a string, or undefined.

function
isFloat→ boolean

Checks if the provided value is a floating-point number.

function
isInt→ boolean

Checks if the provided value is an integer.

function
isObject→ obj is object

Checks if the provided argument is an object and not an array.

function
isString→ boolean

Checks if the provided value is a string that cannot be parsed into a number.

Classes

class
BaseTranslator

Abstract class that provides a blueprint for creating specific translator classes. Defines two abstract methods: formatFunction and mergeFilters.

class
BasicTranslator

Class that extends the BaseTranslator class and provides concrete implementations for the abstract methods. Also declares three types: VisitOperationOutput, VisitComparisonOutput, and VisitStructuredQueryOutput, which are used as the return types for the visitOperation, visitComparison, and visitStructuredQuery methods respectively.

class
Comparison

Class representing a comparison filter directive. It extends the FilterDirective class.

class
Expression

Abstract class representing an expression. Subclasses must implement the exprName property and the accept method.

class
FilterDirective

Abstract class representing a filter directive. It extends the Expression class.

class
FunctionalTranslator

A class that extends BaseTranslator to translate structured queries into functional filters.

class
Operation

Class representing an operation filter directive. It extends the FilterDirective class.

class
StructuredQuery

Class representing a structured query expression. It extends the Expression class.

class
Visitor

Abstract class for visiting expressions. Subclasses must implement visitOperation, visitComparison, and visitStructuredQuery methods.

Type Aliases

typeAlias
AND: "and"

Represents logical AND operator.

typeAlias
Comparator: EQ | NE | LT | GT | LTE | GTE

Represents a comparison operator which can be EQ, NE, LT, GT, LTE, or GTE.

typeAlias
EQ: "eq"

Represents equality comparison operator.

typeAlias
FunctionFilter: (document: Document)

A type alias for a function that takes a Document as an argument and returns a boolean. This function is used as a filter for documents.

typeAlias
GT: "gt"

Represents greater than comparison operator.

typeAlias
GTE: "gte"

Represents greater than or equal to comparison operator.

typeAlias
LT: "lt"

Represents less than comparison operator.

typeAlias
LTE: "lte"

Represents less than or equal to comparison operator.

typeAlias
NE: "ne"

Represents inequality comparison operator.

typeAlias
NOT: "not"

Represents logical NOT operator.

typeAlias
Operator: AND | OR | NOT

Represents a logical operator which can be AND, OR, or NOT.

typeAlias
OR: "or"

Represents logical OR operator.

typeAlias
TranslatorOpts

Options object for the BasicTranslator class. Specifies the allowed operators and comparators.

typeAlias
VisitorComparisonResult: __type

Represents the result of visiting a comparison expression.

typeAlias
VisitorOperationResult: __type

Represents the result of visiting an operation expression.

typeAlias
VisitorResult: VisitorOperationResult | VisitorComparisonResult

Represents the result of visiting an operation or comparison expression.

typeAlias
VisitorStructuredQueryResult

Represents the result of visiting a structured query expression.

Variables

variable
Comparators: __type
variable
Operators: __type
View source on GitHub