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
Fix static linking with libfor.
Kishore Nallanc667ed5d1090
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 19ac62f6..c71afb6a 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -4,8 +4,7 @@ project(search)set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++ -std=gnu++11 -O2")include_directories(include)-include_directories(external/for)-add_executable(search external/for/libfor.a src/art.cpp src/intersection.cpp src/main.cpp)-target_link_libraries(search for)+add_executable(search src/art.cpp src/intersection.cpp src/main.cpp)+target_link_libraries(search ${CMAKE_SOURCE_DIR}/external/for/libfor.a)diff --git a/include/forarray.h b/include/forarray.hindex a2c5ac49..c51de6a2 100644--- a/include/forarray.h+++ b/include/forarray.h@@ -62,8 +62,7 @@ public:}uint32_t indexOf(uint32_t value) {- uint32_t actual;- return for_binary_search(in, length);+ return for_binary_search(in, length, value);}uint32_t* uncompress() {diff --git a/include/matchscore.h b/include/matchscore.hindex 2a08b267..02da896f 100644--- a/include/matchscore.h+++ b/include/matchscore.h@@ -45,7 +45,7 @@ struct MatchScore {* We use a priority queue to read the position vectors in a sorted manner, slide a window of a given size, and* compute the max_match and min_displacement of target tokens across the windows.*/-MatchScore match_score(std::vector<std::vector<uint32_t>> &word_positions) {+MatchScore match_score(std::vector<std::vector<uint16_t>> &word_positions) {std::priority_queue<WordPosition, std::vector<WordPosition>, WordPosition> heap;for(uint8_t word=0; word < word_positions.size(); word++) {diff --git a/src/main.cpp b/src/main.cppindex ae9d5271..d5607b50 100644--- a/src/main.cpp+++ b/src/main.cpp@@ -118,7 +118,7 @@ void find_documents(art_tree & t, string q, size_t max_results) {//cout << "token_leaves.size(): " << token_leaves.size() << endl;- std::vector<std::vector<uint32_t>> word_positions;+ std::vector<std::vector<uint16_t>> word_positions;Topster<100> topster;size_t total_results = 0;const size_t combination_limit = 10;@@ -137,7 +137,7 @@ void find_documents(art_tree & t, string q, size_t max_results) {cout << x->key << ' ';}- // sort based on matched document size to perform effective intersection+ // sort ascending based on matched document size to perform effective intersectionsort(u.begin(), u.end(), [](const art_leaf* left, const art_leaf* right) {return left->values->ids.getLength() < right->values->ids.getLength();});@@ -159,7 +159,8 @@ void find_documents(art_tree & t, string q, size_t max_results) {// go through each document and calculate match scorefor(auto i=0; i<result_size; i++) {for (art_leaf *token_leaf : u) {- vector<uint32_t> positions;+ vector<uint16_t> positions;+ // by using the document id, locate the positions where the token occursuint32_t doc_index = token_leaf->values->ids.indexOf(result[i]);uint32_t offset_index = token_leaf->values->offset_index.at(doc_index);uint32_t num_offsets = token_leaf->values->offsets.at(offset_index);