Skip to content

Apply shared term normalization to search terms, query matchers and the alias index #346

Open

Description

Follow-up to #322 / #325. #325 makes the memory and SQLite term and property indexes share normalize_term (NFC, lowercase, trim, collapse whitespace). Several other places still only call .lower(), so they can disagree with the index keys:

  1. Search side. search.validate_and_prepare_term, searchlib._parse_search_term and query.get_matching_term_for_text (and the entity-matching helpers such as match_entity_name_or_type) still only lowercase. Example: for entity "Space Needle" and search term "space needle", lookup_term finds the semref, but boost_entities compares "space needle" with "space needle" and fails, so the entity loses its boost. Normalizing once in validate_and_prepare_term and in the query matchers would fix this.
  2. Related-terms alias index (storage/memory/related_terms_index.py, storage/sqlite/related_terms_index.py) stores and looks up raw text. An alias registered for "space needle" is missed when the user searches " Space\tNeedle".
  3. The two fuzzy-index update paths collect different terms. ConversationBase incremental updates add only entity names, topic text and action verbs. add_messages._collect_related_terms_for_fuzzy_index uses collect_entity_terms / collect_action_terms, which also include types, facets, subjects and objects. So related-term expansion depends on which ingestion path was used. This was already the case before Share term normalization between memory and SQLite indexes #325.

Found while reviewing #325; left out of it to keep that PR focused on the storage indexes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions