Details
-
Task
-
Resolution: Unresolved
-
Minor
-
4.0.0, 4.1.0
-
None
-
None
-
0
Description
When creating a SearchIndex, if the parameters are not passed in as kwargs, then it is possible a segmentation fault occurs as the order of the parameters then matter. The validation of the SearchIndex should be improved to check types and valid values (as much as possible).
Example:
import pathlib |
import json |
from os import path |
|
from couchbase.auth import PasswordAuthenticator |
from couchbase.cluster import Cluster |
from couchbase.options import ClusterOptions |
|
from couchbase.management.search import SearchIndex |
|
|
TEST_INDEX_NAME = 'test-search-index' |
TEST_INDEX_PATH = path.join(pathlib.Path(__file__).parent, |
'tests', |
'test_cases', |
f'{TEST_INDEX_NAME}-params.json') |
|
|
def load_idx(cluster): |
sixm = cluster.search_indexes() |
with open(TEST_INDEX_PATH) as params_file: |
input = params_file.read() |
params_json = json.loads(input) |
plan_params = { |
'maxPartitionsPerPIndex': 171, |
'numReplicas': 0, |
'indexPartitions': 6 |
}
|
|
# Segmentation fault when not using kwargs |
# idx = SearchIndex(TEST_INDEX_NAME, |
# 'fulltext-index', |
# 'default', |
# '', |
# params_json, |
# '', |
# {}, |
# 'couchbase', |
# plan_params) |
|
# this works |
idx = SearchIndex(name=TEST_INDEX_NAME, |
idx_type='fulltext-index', |
source_name='default', |
uuid='', |
params=params_json, |
source_uuid='', |
source_params={}, |
source_type='couchbase', |
plan_params=plan_params) |
sixm.upsert_index(idx)
|
|
|
if __name__ == '__main__': |
auth = PasswordAuthenticator('Administrator', 'password') |
cluster = Cluster.connect('couchbase://localhost', ClusterOptions(auth)) |
bucket = cluster.bucket('default') |
coll = bucket.default_collection() |
load_idx(cluster)
|
|