Cppinecone
A C++ client for the Pinecone vector database
filters.hpp
Go to the documentation of this file.
1 #pragma once
23 #include <string>
24 
26 
27 namespace pinecone::types::filters
28 {
36 inline auto eq(std::string key, metadata_value value) noexcept -> binary_filter
37 {
38  return {std::move(key), binary_operator::eq, std::move(value)};
39 }
40 
48 inline auto ne(std::string key, metadata_value value) noexcept -> binary_filter
49 {
50  return {std::move(key), binary_operator::ne, std::move(value)};
51 };
52 
60 inline auto gt(std::string key, metadata_value value) noexcept -> binary_filter
61 {
62  return {std::move(key), binary_operator::gt, std::move(value)};
63 };
64 
72 inline auto gte(std::string key, metadata_value value) noexcept -> binary_filter
73 {
74  return {std::move(key), binary_operator::gte, std::move(value)};
75 };
76 
84 inline auto lt(std::string key, metadata_value value) noexcept -> binary_filter
85 {
86  return {std::move(key), binary_operator::lt, std::move(value)};
87 };
88 
96 inline auto lte(std::string key, metadata_value value) noexcept -> binary_filter
97 {
98  return {std::move(key), binary_operator::lte, std::move(value)};
99 };
100 
109 template <typename iter>
110 inline auto in(std::string key, iter values) noexcept -> array_filter<iter>
111 {
112  return {std::move(key), array_operator::in, std::move(values)};
113 };
114 
123 template <typename iter>
124 inline auto nin(std::string key, iter values) noexcept -> array_filter<iter>
125 {
126  return {std::move(key), array_operator::nin, std::move(values)};
127 };
128 
136 template <typename... ts>
137 inline auto and_(ts... filters) noexcept -> combination_filter<ts...>
138 {
139  return {combination_operator::and_, std::move(filters)...};
140 };
141 
149 template <typename... ts>
150 inline auto or_(ts... filters) noexcept -> combination_filter<ts...>
151 {
152  return {combination_operator::or_, std::move(filters)...};
153 };
154 
160 inline auto none() noexcept -> no_filter { return {}; };
161 } // namespace pinecone::types::filters
auto gt(std::string key, metadata_value value) noexcept -> binary_filter
Greater-than filter, tests if a key is > than a value.
Definition: filters.hpp:60
auto in(std::string key, iter values) noexcept -> array_filter< iter >
In filter, tests if a key is in a range of values.
Definition: filters.hpp:110
auto nin(std::string key, iter values) noexcept -> array_filter< iter >
Not-in filter, tests is a key is not in a range of values.
Definition: filters.hpp:124
auto and_(ts... filters) noexcept -> combination_filter< ts... >
And filter, tests if all contained filters are true.
Definition: filters.hpp:137
auto gte(std::string key, metadata_value value) noexcept -> binary_filter
Greater-than-or-equal filter, tests if a key is >= a value.
Definition: filters.hpp:72
auto or_(ts... filters) noexcept -> combination_filter< ts... >
Or filter, tests is any contained filter is true.
Definition: filters.hpp:150
auto ne(std::string key, metadata_value value) noexcept -> binary_filter
Not-equal filter, tests if a key is != to a value.
Definition: filters.hpp:48
auto lte(std::string key, metadata_value value) noexcept -> binary_filter
Less-than-or-equal filter, tests if a key is <= a value.
Definition: filters.hpp:96
auto eq(std::string key, metadata_value value) noexcept -> binary_filter
Equality filter, tests if a key is == to a value.
Definition: filters.hpp:36
auto none() noexcept -> no_filter
No filter, always true.
Definition: filters.hpp:160
auto lt(std::string key, metadata_value value) noexcept -> binary_filter
Less-than filter, tests if a key is < a value.
Definition: filters.hpp:84
T move(T... args)
Array filters test a single metadata value against multiple operands.
Binary filters are simple predicates; they compare a single metadata value to a provided operand.
Combination filters apply boolean logic to the other filter types.
No filter applied; always returns true.
Encoding for Pinecone's vector metadata API.