|
|
@@ -1177,7 +1177,21 @@ struct HostContext::Impl {
|
|
|
// expiry to preserve, so "say nothing" and "no expiry" are the same
|
|
|
// thing - which is also what POST /documents does with the parameter.
|
|
|
const uint32_t ttl = hostdetail::ttlFrom(payload).value_or(0);
|
|
|
- meta(collection);
|
|
|
+ // The same refusal POST /documents makes, for the same reason: a
|
|
|
+ // document inserted into a VECTOR collection with no vector reads back
|
|
|
+ // perfectly and can never be found by a search. The two routes are the
|
|
|
+ // same operation and must not drift.
|
|
|
+ //
|
|
|
+ // `text` does not satisfy it here either, and for the identical reason:
|
|
|
+ // .insert() DOES NOT EMBED. Only .store() does. Accepting `text` would
|
|
|
+ // store an invisible row while appearing to permit ordinary ingest.
|
|
|
+ const CollectionMeta& m = meta(collection);
|
|
|
+ if (m.kind == "vector" && !doc.contains("_vector") && !doc.contains("vector"))
|
|
|
+ throw ApiError(ErrCode::Unprocessable, "vector_missing",
|
|
|
+ "a document inserted into vector collection '" + collection +
|
|
|
+ "' must carry '_vector', or it can never be found by a search. "
|
|
|
+ ".insert() does not embed: use .store({text}) to have text embedded, "
|
|
|
+ "or .store({vector}) to supply one");
|
|
|
std::string newId;
|
|
|
try {
|
|
|
newId = db.client().insert(qualify(config.project, collection), doc, id, ttl,
|