-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: fix table post/put api bug #172
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,14 +116,42 @@ def _get_search_result(self, page_index: int, | |
|
||
for hit in response: | ||
try: | ||
# ES hit: {'_d_': {'key': xxx...} | ||
es_metadata = hit.__dict__.get('meta', {}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it has been a while, could you add an example on the return value of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure, will do. |
||
""" | ||
ES hit example: | ||
{ | ||
'_d_': { | ||
'name': 'name', | ||
'database': 'database', | ||
'schema': 'schema', | ||
'key': 'database://cluster.schema/name', | ||
'cluster': 'cluster', | ||
'column_descriptions': ['description1', 'description2'], | ||
'column_names': ['colname1', 'colname2'], | ||
'description': None, | ||
'display_name': 'display name', | ||
'last_updated_timestamp': 12345678, | ||
'programmatic_descriptions': [], | ||
'schema_description': None, | ||
'tags': ['tag1', 'tag2'], | ||
'badges': [], | ||
'total_usage': 0 | ||
}, | ||
'mata': { | ||
'index': 'table index', | ||
'id': 'table id', | ||
'type': 'type' | ||
} | ||
} | ||
""" | ||
es_payload = hit.__dict__.get('_d_', {}) | ||
if not es_payload: | ||
raise Exception('The ES doc not contain required field') | ||
result = {} | ||
for attr, val in es_payload.items(): | ||
if attr in model.get_attrs(): | ||
result[attr] = self._get_instance(attr=attr, val=val) | ||
result['id'] = self._get_instance(attr='id', val=es_metadata['id']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the id is ES document id? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes |
||
|
||
results.append(model(**result)) | ||
except Exception: | ||
|
@@ -590,7 +618,7 @@ def _build_update_actions(self, data: List[Table], index_key: str) -> List[Dict[ | |
|
||
for item in data: | ||
actions.append({'update': {'_index': index_key, '_type': item.get_type(), '_id': item.get_id()}}) | ||
actions.append({'doc': item.__dict__}) | ||
actions.append({'doc': item.get_attrs_dict()}) | ||
return actions | ||
|
||
def _build_delete_actions(self, data: List[str], index_key: str, type: str) -> List[Dict[str, Any]]: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this id is same as table key or the ES document id?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ES document id is always root of truth, but we can also use key as the ES document id (assuming key is unique)