Merge branch 'v0.25-join' into v0.26-facets

This commit is contained in:
Kishore Nallan 2023-08-07 08:32:12 +05:30
commit b779713fdb
4 changed files with 88 additions and 23 deletions

View File

@ -1,7 +1,7 @@
name: tests
#on: [push, pull_request]
on: workflow_dispatch
#on: workflow_dispatch
on: [push, pull_request]
# Cancel previous running if a new push is made
# Source: https://stackoverflow.com/a/72408109/123545
@ -21,40 +21,69 @@ jobs:
run: |
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install -y g++-10 make git zlib1g-dev m4
# Define the compiler
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 30
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 30
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudo update-alternatives --set cc /usr/bin/gcc
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
sudo update-alternatives --set c++ /usr/bin/g++
- name: Set up Bazel
uses: bazelbuild/setup-bazelisk@v2
- name: Restore bazel cache
uses: actions/cache@v3
- name: Download bazel cache
uses: dawidd6/action-download-artifact@v2
with:
path: |
~/.cache/bazel
# Source: https://github.com/actions/cache/blob/67b839edb68371cc5014f6cea11c9aa77238de78/examples.md#linux-2
key: ${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE', 'WORKSPACE.bazel', 'MODULE.bazel') }}
restore-keys: |
${{ runner.os }}-bazel-
name: bazel-cache
search_artifacts: true
workflow_conclusion: ""
if_no_artifact_found: warn
- name: Uncompress bazel cache
run: |
mkdir -p ~/.cache/bazel
tar_file="bazel-cache.tar.gz" && \
[ -f "$tar_file" ] && \
tar -xzvf "$tar_file" -C ~/.cache/bazel && \
rm bazel-cache.tar.gz
exit 0
- name: Build protobuf deps
run: |
bazel build @com_google_protobuf//:protobuf_headers
bazel build @com_google_protobuf//:protobuf_lite
bazel build @com_google_protobuf//:protobuf
bazel build @com_google_protobuf//:protoc
- name: Build Typesense
run: bazel build //:typesense-server
- name: Run tests
run: bazel test --test_output=all -- //:typesense-test
run: bazel test //:typesense-test
- name: Compress bazel cache
if: always()
run: |
tar -czvf bazel-cache.tar.gz -C ~/.cache/bazel .
- name: Save bazel cache
uses: actions/upload-artifact@v3
if: always()
with:
name: bazel-cache
path: bazel-cache.tar.gz
if-no-files-found: warn
retention-days: 10
# Source: https://github.com/actions/upload-artifact/issues/92#issuecomment-1080347032
- run: echo "BAZEL_BIN_FULL_PATH=$(readlink -f bazel-bin)" >> $GITHUB_ENV
- name: Set BAZEL_BIN_FULL_PATH
run: echo "BAZEL_BIN_FULL_PATH=$(readlink -f bazel-bin)" >> $GITHUB_ENV
- name: Save build artifacts
uses: actions/upload-artifact@v3
with:

View File

@ -30,9 +30,9 @@ cmake(
install = False,
cache_entries = {
'SPM_USE_BUILTIN_PROTOBUF': 'OFF',
'Protobuf_LIBRARY': '$INSTALLDIR/../../com_google_protobuf/libprotobuf.a',
'Protobuf_LITE_LIBRARY': '$INSTALLDIR/../../com_google_protobuf/libprotobuf-lite.a',
'Protobuf_PROTOC_EXECUTABLE': '$INSTALLDIR/../../com_google_protobuf/protoc',
'Protobuf_LIBRARY': '$$BUILD_TMPDIR$$/../../com_google_protobuf/libprotobuf.a',
'Protobuf_LITE_LIBRARY': '$$BUILD_TMPDIR$$/../../com_google_protobuf/libprotobuf-lite.a',
'Protobuf_PROTOC_EXECUTABLE': '$$BUILD_TMPDIR$$/../../com_google_protobuf/protoc',
'Protobuf_INCLUDE_DIR': '$EXT_BUILD_ROOT/external/com_google_protobuf/src',
'CMAKE_POLICY_DEFAULT_CMP0111':'OLD'
},
@ -44,7 +44,7 @@ cmake(
],
tags = ["no-sandbox"],
postfix_script= """
echo "Intstalling sentencepiece"
cp $BUILD_TMPDIR/src/libsentencepiece.a $INSTALLDIR/lib/libsentencepiece.a
"""
echo "Installing sentencepiece"
cp $BUILD_TMPDIR/src/libsentencepiece.a $INSTALLDIR/lib/libsentencepiece.a
"""
)

View File

@ -365,7 +365,7 @@ bool field::flatten_obj(nlohmann::json& doc, nlohmann::json& value, bool has_arr
continue;
}
if(std::regex_match(flat_name, std::regex(flat_name))) {
if(std::regex_match(flat_name, std::regex(dynamic_field.name))) {
detected_type = dynamic_field.type;
found_dynamic_field = true;
break;

View File

@ -2867,6 +2867,42 @@ TEST_F(CollectionNestedFieldsTest, FloatInsideNestedObject) {
ASSERT_TRUE(add_op.ok());
}
TEST_F(CollectionNestedFieldsTest, NestedFieldWithRegexName) {
nlohmann::json schema = R"({
"name": "coll1",
"enable_nested_fields": true,
"fields": [
{"name":"titles", "type":"object"},
{"name": "titles\\..*", "type":"string"},
{"name":"start_date", "type":"object"},
{"name":"start_date\\..*", "type":"int32", "facet":true, "optional":true}
]
})"_json;
auto op = collectionManager.create_collection(schema);
ASSERT_TRUE(op.ok());
Collection *coll1 = op.get();
auto doc1 = R"({
"titles": {
"en": "Foobar baz"
},
"start_date": {
"year": 2020,
"month": 2,
"day": 3
}
})"_json;
auto add_op = coll1->add(doc1.dump(), CREATE);
ASSERT_TRUE(add_op.ok());
auto results = coll1->search("foobar", {"titles.en"}, "start_date.year: 2020", {}, {}, {2}, 10,
1, FREQUENCY, {true}).get();
ASSERT_EQ(1, results["found"].get<size_t>());
}
TEST_F(CollectionNestedFieldsTest, HighlightOnFlatFieldWithSnippeting) {
std::vector<field> fields = {field("title", field_types::STRING, false),
field("body", field_types::STRING, false)};