def _clean_search_results(self, results: list[dict], for_display: bool = True) -> list[dict]:
        """Clean search results by removing large fields and optionally truncating content.

        Args:
            results: Raw search results from vector database
            for_display: If True, truncate large text fields for frontend display.
                        If False, only remove truly unnecessary fields (vectors, download_urls)

        Returns:
            Cleaned search results
        """
        cleaned_results = []

        for result in results:
            if not isinstance(result, dict):
                cleaned_results.append(result)
                continue

            cleaned_result = result.copy()

            if "payload" in cleaned_result and isinstance(cleaned_result["payload"], dict):
                payload = cleaned_result["payload"].copy()

                # Always remove these fields - they're too large or unnecessary
                fields_to_always_remove = [
                    "vector",
                    "download_url",
                    "local_path",
                    "file_uuid",
                    "checksum",
                ]
                for field in fields_to_always_remove:
                    payload.pop(field, None)

                if for_display:
                    # Handle nested JSON strings - parse them for better display
                    json_fields = ["metadata", "sync_metadata", "auth_fields", "config_fields"]
                    for field in json_fields:
                        if field in payload and isinstance(payload[field], str):
                            try:
                                # Try to parse JSON string to object for better display
                                payload[field] = json.loads(payload[field])
                            except json.JSONDecodeError:
                                # If it's not valid JSON, keep as is (no truncation)
                                pass

                cleaned_result["payload"] = payload

            cleaned_results.append(cleaned_result)

        return cleaned_results
Clean search results by removing large fields and optionally truncating content.

        Args:
            results: Raw search results from vector database
            for_display: If True, truncate large text fields for frontend display.
                        If False, only remove truly unnecessary fields (vectors, download_urls)

        Returns:
            Cleaned search results
        
backend/airweave/core/search_service.py