feat(search): enhance V3 ID Vision mapping and searchable fields
- Update lib_sql_search.py to include comprehensive 'vision_fields' mapping for most core objects - Ensure Vision Mapping only triggers for non-integer values to support backend filters - Add clean ID names (e.g., 'event_id', 'account_id') to searchable_fields whitelists in Events, Badges, and Journal object definitions - Resolve Concatenation typo in vision_fields list - Improve searchability for Journal Entries by adding 'default_qry_str'
This commit is contained in:
@@ -213,32 +213,46 @@ def sql_search_qry_part(
|
|||||||
target_field = f.field
|
target_field = f.field
|
||||||
vision_fields = [
|
vision_fields = [
|
||||||
'id', 'account_id', 'site_id', 'person_id', 'user_id',
|
'id', 'account_id', 'site_id', 'person_id', 'user_id',
|
||||||
'journal_id', 'journal_entry_id', 'page_id', 'post_id',
|
'archive_id', 'archive_content_id',
|
||||||
'post_comment_id', 'organization_id', 'address_id', 'hosted_file_id'
|
'event_id',
|
||||||
|
'event_session_id', 'event_presentation_id', 'event_presenter_id',
|
||||||
|
'event_device_id', 'event_location_id', 'event_track_id',
|
||||||
|
'event_exhibit_id',
|
||||||
|
'event_person_id', 'event_registration_id',
|
||||||
|
'order_id', 'product_id', 'order_cart_id', 'membership_id', 'sponsorship_id',
|
||||||
|
'journal_id', 'journal_entry_id', 'page_id',
|
||||||
|
'post_id', 'post_comment_id',
|
||||||
|
'organization_id', 'address_id', 'contact_id',
|
||||||
|
'hosted_file_id'
|
||||||
]
|
]
|
||||||
|
|
||||||
if target_field in vision_fields:
|
if target_field in vision_fields:
|
||||||
candidate_field = 'id_random' if target_field == 'id' else f"{target_field}_random"
|
# ONLY map to _random if the value is a string (looks like a random ID)
|
||||||
|
# If it's an integer, we want to query the original integer column.
|
||||||
|
is_int_val = isinstance(f.value, int) or (isinstance(f.value, str) and f.value.isdigit())
|
||||||
|
|
||||||
# Schema Check: Verify if the random version exists in the current table/view
|
if not is_int_val:
|
||||||
use_random = False
|
candidate_field = 'id_random' if target_field == 'id' else f"{target_field}_random"
|
||||||
if table_name:
|
|
||||||
try:
|
# Schema Check: Verify if the random version exists in the current table/view
|
||||||
with lib_sql_core.engine.connect() as conn:
|
use_random = False
|
||||||
conn.execute(text(f"SELECT `{candidate_field}` FROM `{table_name}` LIMIT 0"))
|
if table_name:
|
||||||
use_random = True
|
try:
|
||||||
except Exception:
|
with lib_sql_core.engine.connect() as conn:
|
||||||
|
conn.execute(text(f"SELECT `{candidate_field}` FROM `{table_name}` LIMIT 0"))
|
||||||
|
use_random = True
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if use_random:
|
||||||
|
target_field = candidate_field
|
||||||
|
# print(f"Search Trace: Mapping filter field '{f.field}' -> '{target_field}'", flush=True)
|
||||||
|
else:
|
||||||
|
# If random doesn't exist, we must stick to the integer column
|
||||||
|
# but we'll need to resolve the string value to an integer elsewhere
|
||||||
|
# or rely on the user providing an integer for now.
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if use_random:
|
|
||||||
target_field = candidate_field
|
|
||||||
# print(f"Search Trace: Mapping filter field '{f.field}' -> '{target_field}'", flush=True)
|
|
||||||
else:
|
|
||||||
# If random doesn't exist, we must stick to the integer column
|
|
||||||
# but we'll need to resolve the string value to an integer elsewhere
|
|
||||||
# or rely on the user providing an integer for now.
|
|
||||||
pass
|
|
||||||
|
|
||||||
if searchable_fields is not None and target_field not in searchable_fields:
|
if searchable_fields is not None and target_field not in searchable_fields:
|
||||||
# Fallback check for original field just in case
|
# Fallback check for original field just in case
|
||||||
if f.field not in searchable_fields:
|
if f.field not in searchable_fields:
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ events_general_obj_li = {
|
|||||||
],
|
],
|
||||||
# V3 Search Security:
|
# V3 Search Security:
|
||||||
'searchable_fields': [
|
'searchable_fields': [
|
||||||
|
'account_id', 'event_id',
|
||||||
'event_id_random', 'account_id_random', 'event_code', 'conference',
|
'event_id_random', 'account_id_random', 'event_code', 'conference',
|
||||||
'type', 'name', 'summary', 'description', 'format', 'timezone',
|
'type', 'name', 'summary', 'description', 'format', 'timezone',
|
||||||
'location_text', 'status', 'enable', 'hide', 'priority', 'sort',
|
'location_text', 'status', 'enable', 'hide', 'priority', 'sort',
|
||||||
@@ -67,6 +68,7 @@ events_general_obj_li = {
|
|||||||
'public_read': True,
|
'public_read': True,
|
||||||
# V3 Search Security:
|
# V3 Search Security:
|
||||||
'searchable_fields': [
|
'searchable_fields': [
|
||||||
|
'event_id', 'event_file_id', 'hosted_file_id',
|
||||||
'event_file_id_random', 'hosted_file_id_random', 'event_id_random',
|
'event_file_id_random', 'hosted_file_id_random', 'event_id_random',
|
||||||
'event_exhibit_id_random', 'event_location_id_random',
|
'event_exhibit_id_random', 'event_location_id_random',
|
||||||
'event_presentation_id_random', 'event_presenter_id_random',
|
'event_presentation_id_random', 'event_presenter_id_random',
|
||||||
|
|||||||
@@ -20,7 +20,10 @@ events_registration_obj_li = {
|
|||||||
'base_name': Event_Badge_Basic_Base,
|
'base_name': Event_Badge_Basic_Base,
|
||||||
# V3 Search Security:
|
# V3 Search Security:
|
||||||
'searchable_fields': [
|
'searchable_fields': [
|
||||||
'event_badge_id_random', 'event_badge_template_id_random',
|
'account_id', 'event_badge_id', 'event_badge_template_id',
|
||||||
|
'event_id',
|
||||||
|
'account_id_random', 'event_badge_id_random', 'event_badge_template_id_random',
|
||||||
|
'event_id_random',
|
||||||
'event_person_id_random', 'external_id', 'pronouns', 'informal_name',
|
'event_person_id_random', 'external_id', 'pronouns', 'informal_name',
|
||||||
'title_names', 'given_name', 'middle_name', 'family_name', 'designations',
|
'title_names', 'given_name', 'middle_name', 'family_name', 'designations',
|
||||||
'professional_title', 'full_name', 'affiliations', 'email', 'phone',
|
'professional_title', 'full_name', 'affiliations', 'email', 'phone',
|
||||||
@@ -43,6 +46,7 @@ events_registration_obj_li = {
|
|||||||
'base_name': Event_Badge_Template_Base,
|
'base_name': Event_Badge_Template_Base,
|
||||||
# V3 Search Security:
|
# V3 Search Security:
|
||||||
'searchable_fields': [
|
'searchable_fields': [
|
||||||
|
'event_badge_template_id', 'event_id',
|
||||||
'event_badge_template_id_random', 'event_id_random', 'name',
|
'event_badge_template_id_random', 'event_id_random', 'name',
|
||||||
'description', 'layout', 'notes', 'enable',
|
'description', 'layout', 'notes', 'enable',
|
||||||
'created_on', 'updated_on'
|
'created_on', 'updated_on'
|
||||||
|
|||||||
@@ -23,8 +23,9 @@ journal_obj_li = {
|
|||||||
'id', 'account_id', 'person_id', 'user_id',
|
'id', 'account_id', 'person_id', 'user_id',
|
||||||
'journal_id_random', 'account_id_random', 'person_id_random', 'user_id_random',
|
'journal_id_random', 'account_id_random', 'person_id_random', 'user_id_random',
|
||||||
'name', 'short_name', 'summary', 'outline',
|
'name', 'short_name', 'summary', 'outline',
|
||||||
'description', 'type_code', 'tags', 'billable', 'enable', 'hide',
|
'description', 'type_code', 'tags', 'billable',
|
||||||
'priority', 'sort', 'group', 'notes', 'created_on', 'updated_on', 'default_qry_str'
|
'enable', 'hide', 'priority', 'sort', 'group', 'notes',
|
||||||
|
'created_on', 'updated_on', 'default_qry_str'
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
'journal_entry': {
|
'journal_entry': {
|
||||||
@@ -48,8 +49,8 @@ journal_obj_li = {
|
|||||||
'journal_entry_id_random', 'journal_id_random', 'account_id_random',
|
'journal_entry_id_random', 'journal_id_random', 'account_id_random',
|
||||||
'name', 'short_name',
|
'name', 'short_name',
|
||||||
'summary', 'content', 'type_code', 'topic_code', 'category_code',
|
'summary', 'content', 'type_code', 'topic_code', 'category_code',
|
||||||
'tags', 'location', 'billable', 'enable', 'hide', 'priority', 'sort',
|
'tags', 'location', 'billable', 'enable', 'hide', 'priority', 'enable', 'hide', 'priority', 'sort', 'group', 'notes',
|
||||||
'group', 'notes', 'created_on', 'updated_on'
|
'created_on', 'updated_on', 'default_qry_str'
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user