Feilong Hou e4b0f48bc0
test: add e2e test cases for highlighter (#46505)
### **User description**
Issue: #46504 
test: create e2e test case for highlighter

 On branch feature/highlighter
 Changes to be committed:
	new file:   milvus_client/test_milvus_client_highlighter.py


___

### **PR Type**
Tests


___

### **Description**
- Add comprehensive e2e test suite for LexicalHighlighter functionality

- Test highlighter initialization with collection setup and data
insertion

- Validate highlighter with various parameters (tags, fragments,
offsets)

- Test edge cases including Chinese characters, long text, and invalid
inputs

- Verify error handling for invalid fragment sizes, offsets, and
configurations


___

### Diagram Walkthrough


```mermaid
flowchart LR
  A["Test Suite Setup"] --> B["Highlighter Init Tests"]
  B --> C["Valid Test Cases"]
  C --> D["Fragment Parameters"]
  C --> E["Search Variations"]
  C --> F["Language Support"]
  B --> G["Invalid Test Cases"]
  G --> H["Parameter Validation"]
  G --> I["Error Handling"]
```



<details><summary><h3>File Walkthrough</h3></summary>

<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Tests</strong></td><td><table>
<tr>
  <td>
    <details>

<summary><strong>test_milvus_client_highlighter.py</strong><dd><code>Add
comprehensive LexicalHighlighter e2e test suite</code>&nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

tests/python_client/milvus_client/test_milvus_client_highlighter.py

<ul><li>Create new test file with 1163 lines of comprehensive
highlighter test <br>cases<br> <li> Implement
<code>TestMilvusClientHighlighterInit</code> class to initialize
<br>collection with pre-defined test data including English, Chinese,
and <br>long text samples<br> <li> Implement
<code>TestMilvusClientHighlighterValid</code> class with 15+ test
methods <br>covering basic usage, multiple tags, fragment parameters,
offsets, <br>numbers, sentences, and language support<br> <li> Implement
<code>TestMilvusClientHighlighterInvalid</code> class with 8+ test
<br>methods validating error handling for invalid parameters and
<br>configurations<br> <li> Test highlighter with BM25 search, text
matching, and various analyzer <br>configurations</ul>


</details>


  </td>
<td><a
href="https://github.com/milvus-io/milvus/pull/46505/files#diff-443e3fefb65fbdb088d5920083306ecfe3605745b1e2714198c6566ca67b3736">+1163/-0</a></td>

</tr>
</table></td></tr></tbody></table>

</details>

___



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Tests**
  * Added a comprehensive highlighter test suite covering:
- Core highlighting with single and multi-analyzer setups and multi-tag
variations
    - Fragment parameter behaviors and edge cases (size, offset, count)
- Text-match and query-based highlighting, including BM25 and vector
interactions
- Sub-word, long-text/tag, case sensitivity, Chinese/multi-language
scenarios
- Error handling for invalid parameters, no-match cases, and other edge
conditions
- Module-scoped fixture preparing multilingual, long-form test data and
teardown

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Eric Hou <eric.hou@zilliz.com>
Co-authored-by: Eric Hou <eric.hou@zilliz.com>
2025-12-24 09:49:19 +08:00
..