pub struct Payload(/* private fields */);Expand description
Point payload
A JSON-like object that can be attached to points. With payloads you can store any kind of information along with your points. Qdrant provides comprehensive ways to filter on payload values during vector search.
Payload documentation: https://qdrant.tech/documentation/concepts/payload/
§Serde
Requires serde feature
Serde JSON types can be converted to and from Payload. Note that a valid
payload must be a JSON object, and not another JSON type.
Convert a JSON Value to and from Payload:
use serde_json::{Value, json};
let value = json!({
"city": "Berlin",
});
let payload = Payload::try_from(value).expect("not a JSON object");
let value = Value::from(payload);If the above value is not a JSON object, a QdrantError::JsonToPayload error is returned.
Convert a JSON object (Map<String, Value>) to and from from Payload:
use serde_json::{Map, Value};
let mut object = Map::new();
object.insert("city".to_string(), "Berlin".into());
let payload = Payload::from(object);
let object = Map::from(payload);Implementations§
Source§impl Payload
impl Payload
Sourcepub fn new_from_hashmap(payload: HashMap<String, Value>) -> Self
👎Deprecated since 1.10.0: use Payload::from instead
pub fn new_from_hashmap(payload: HashMap<String, Value>) -> Self
Payload::from insteadConstruct a payload object from the given hash map
Sourcepub fn insert(&mut self, key: impl ToString, val: impl Into<Value>)
pub fn insert(&mut self, key: impl ToString, val: impl Into<Value>)
Insert a payload value at the given key, replacing any existing value
Sourcepub fn deserialize<T: DeserializeOwned>(self) -> Result<T, QdrantError>
pub fn deserialize<T: DeserializeOwned>(self) -> Result<T, QdrantError>
Deserializes the payload directly into T. This requires T to implement serde::Deserialize.
Returns an error if T and the payload have a different structure.
use qdrant_client::Payload;
use serde_json::json;
use serde::Deserialize;
#[derive(Deserialize)]
struct MyData {
value1: String,
value2: u32,
}
let payload: Payload = json!({
"value1": "Qdrant",
"value2": 42,
})
.try_into()
.unwrap();
let parsed: MyData = payload.deserialize().unwrap();
assert_eq!(parsed.value1, "Qdrant");
assert_eq!(parsed.value2, 42);Trait Implementations§
Source§impl<'de> Deserialize<'de> for Payload
impl<'de> Deserialize<'de> for Payload
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl TryFrom<Value> for Payload
Available on crate feature serde only.
impl TryFrom<Value> for Payload
serde only.Source§fn try_from(value: Value) -> Result<Self, Self::Error>
fn try_from(value: Value) -> Result<Self, Self::Error>
Convert JSON object into payload
The JSON value must be a valid object. A JSON object of type
Map<String, Value> can be converted without errors using
Payload::from.
§Errors
Returns an QdrantError::JsonToPayload error if the
value is not an object.
Source§type Error = QdrantError
type Error = QdrantError
impl StructuralPartialEq for Payload
Auto Trait Implementations§
impl Freeze for Payload
impl RefUnwindSafe for Payload
impl Send for Payload
impl Sync for Payload
impl Unpin for Payload
impl UnwindSafe for Payload
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request