Skip to main content

English

The english analyzer in Zilliz Cloud is designed to process English text, applying language-specific rules for tokenization and filtering.

Definition​

The english analyzer uses the following components:

  • Tokenizer: Uses the standard tokenizer to split text into discrete word units.

  • Filters: Includes multiple filters for comprehensive text processing:

    • lowercase: Converts all tokens to lowercase, enabling case-insensitive searches.

    • stemmer: Reduces words to their root form to support broader matching (e.g., "running" becomes "run").

    • stop_words: Removes common English stop words to focus on key terms in text.

The functionality of the english analyzer is equivalent to the following custom analyzer configuration:

python
analyzer_params = {
"tokenizer": "standard",
"filter": [
"lowercase",
{
"type": "stemmer",
"language": "english"
}, {
"type": "stop",
"stop_words": "_english_"
}
]
}

Configuration​

To apply the english analyzer to a field, simply set type to english in analyzer_params, and include optional parameters as needed.

python
analyzer_params = {
"type": "english",
}

The english analyzer accepts the following optional parameters:

ParameterDescription
stop_wordsAn array containing a list of stop words, which will be removed from tokenization. Defaults to _english_, a built-in set of common English stop words.

Example configuration with custom stop words:

python
analyzer_params = {
"type": "english",
"stop_words": ["a", "an", "the"]
}

After defining analyzer_params, you can apply them to a VARCHAR field when defining a collection schema. This allows Zilliz Cloud to process the text in that field using the specified analyzer for efficient tokenization and filtering. For details, refer to Example use.

Examples​

Before applying the analyzer configuration to your collection schema, verify its behavior using the run_analyzer method.

Analyzer configuration​

python
analyzer_params = {
"type": "english",
"stop_words": ["a", "an", "the"]
}

Verification using run_analyzer​

python
from pymilvus import (
MilvusClient,
)

client = MilvusClient(
uri="YOUR_CLUSTER_ENDPOINT",
token="YOUR_CLUSTER_TOKEN"
)

# Sample text to analyze
sample_text = "Milvus is a vector database built for scale!"

# Run the standard analyzer with the defined configuration
result = client.run_analyzer(sample_text, analyzer_params)
print("English analyzer output:", result)

Expected output​

python
English analyzer output: ['milvus', 'vector', 'databas', 'built', 'scale']