Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences
C++ algoliadatastoreelasticsearchenterprise-searchfacetingfull-text-searchfuzzy-searchgeosearchin-memoryinstantsearchmerchandisingpineconesearchsearch-enginesemantic-searchsimilarity-searchsite-searchsynonymstypo-tolerancevector-search
Merge branch 'v0.25' into v0.25-join
Kishore Nallanb03c84cb4a75
diff --cc .gitignoreindex c111898e,a1f055cb..264c40e2--- a/.gitignore+++ b/.gitignore@@@ -13,4 -14,3 +14,5 @@@ cmake-build-releastypesense-server-data/.clwb/.bazelproject.vscode/settings.json- /onnxruntime-prefix++/onnxruntime-prefix++diff --cc include/field.hindex eca39f1e,bb6d9dc2..fa78e730--- a/include/field.h+++ b/include/field.h@@@ -867,4 -768,4 +868,4 @@@ struct facet_hash_values_tuint64_t back() const {return hashes[length - 1];}--};++};diff --cc src/collection.cppindex 54dc6b87,32bdfc29..2aed0768--- a/src/collection.cpp+++ b/src/collection.cpp@@@ -1496,10 -1390,9 +1498,12 @@@ Option<nlohmann::json> Collection::searfilter_curated_hits, split_join_tokens, vector_query,facet_sample_percent, facet_sample_threshold);+ std::unique_ptr<search_args> search_params_guard(search_params);+- index->run_search(search_params);+ auto search_op = index->run_search(search_params, name);+ if (!search_op.ok()) {+ return Option<nlohmann::json>(search_op.code(), search_op.error());+ }// for grouping we have to re-aggregate@@@ -4631,33 -4391,3 +4644,33 @@@ Option<bool> Collection::populate_inclustd::shared_lock lock(mutex);return populate_include_exclude_fields(include_fields, exclude_fields, include_fields_full, exclude_fields_full);}+++Option<bool> Collection::embed_fields(nlohmann::json& document) {+ for(const auto& field : fields) {+ if(field.create_from.size() > 0) {+ if(TextEmbedderManager::model_dir.empty()) {+ return Option<bool>(400, "Text embedding is not enabled. Please set `model-dir` at startup.");+ }+ std::string text_to_embed;+ for(const auto& field_name : field.create_from) {+ auto field_it = document.find(field_name);+ if(field_it != document.end()) {+ if(field_it->is_string()) {+ text_to_embed += field_it->get<std::string>() + " ";+ } else {+ return Option<bool>(400, "Field `" + field_name + "` is not a string.");+ }+ } else {+ return Option<bool>(400, "Field `" + field_name + "` not found in document.");+ }+ }++ TextEmbedderManager& embedder_manager = TextEmbedderManager::get_instance();+ auto embedder = embedder_manager.get_text_embedder(field.model_name.size() > 0 ? field.model_name : TextEmbedderManager::DEFAULT_MODEL_NAME);+ std::vector<float> embedding = embedder->Embed(text_to_embed);+ document[field.name] = embedding;+ }+ }+ return Option<bool>(true);- }++}diff --cc src/field.cppindex 0e4b5193,6ae9c989..740026b1--- a/src/field.cpp+++ b/src/field.cpp@@@ -413,32 -409,14 +414,38 @@@ Option<bool> toParseTree(std::queue<stdfilter_node = new filter_node_t(expression == "&&" ? AND : OR, operandA, operandB);} else {filter filter_exp;- Option<bool> toFilter_op = toFilter(expression, filter_exp, search_schema, store, doc_id_prefix);- if (!toFilter_op.ok()) {- while(!nodeStack.empty()) {- auto filterNode = nodeStack.top();- delete filterNode;- nodeStack.pop();++<<<<<<< HEAD++ // Expected value: $Collection(...)+ bool is_referenced_filter = (expression[0] == '$' && expression[expression.size() - 1] == ')');+ if (is_referenced_filter) {+ size_t parenthesis_index = expression.find('(');++ std::string collection_name = expression.substr(1, parenthesis_index - 1);+ auto& cm = CollectionManager::get_instance();+ auto collection = cm.get_collection(collection_name);+ if (collection == nullptr) {+ return Option<bool>(400, "Referenced collection `" + collection_name + "` not found.");+ }++ filter_exp = {expression.substr(parenthesis_index + 1, expression.size() - parenthesis_index - 2)};+ filter_exp.referenced_collection_name = collection_name;++ auto op = collection->validate_reference_filter(filter_exp.field_name);+ if (!op.ok()) {+ return Option<bool>(400, "Failed to parse reference filter on `" + collection_name ++ "` collection: " + op.error());+ }+ } else {+ Option<bool> toFilter_op = toFilter(expression, filter_exp, search_schema, store, doc_id_prefix);+ if (!toFilter_op.ok()) {++ while(!nodeStack.empty()) {++ auto filterNode = nodeStack.top();++ delete filterNode;++ nodeStack.pop();++ }+ return toFilter_op;}- return toFilter_op;}filter_node = new filter_node_t(filter_exp);