Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION]: (code=1100, message=only BM25 Function output field support BM25 metric type: invalid parameter[expected=valid index params][actual=invalid index params]) #2545

Open
1 task done
Newxinchen opened this issue Jan 6, 2025 · 0 comments
Labels
kind/question A question to answer

Comments

@Newxinchen
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

What is your question?

<MilvusException: (code=1100, message=only BM25 Function output field support BM25 metric type: invalid parameter[expected=valid index params][actual=invalid index params])>

The following is the key part of the code. Why can't I create the bm25 index?

Anything else?

def create_vector_index(collection, field_name="embedding", index_params=None):
    if index_type == 'BM25':
        index_params = {
            "index_type": "SPARSE_INVERTED_INDEX",
            "metric_type": "BM25",
            "params": {"bm25_k1": 1.2, "bm25_b": 0.75}
        }

    collection.create_index(field_name, index_params)


collection_fields = [
    FieldSchema(name="id", dtype=DataType.VARCHAR, max_length=32, is_primary=True),
    FieldSchema(name="title", dtype=DataType.VARCHAR, max_length=512),
    FieldSchema(name="bm25_sparse", dtype=DataType.SPARSE_FLOAT_VECTOR)
]
schema = CollectionSchema(fields=collection_fields, description=desc)


bm25_function = Function(
    name="bm25_fn",
    input_field_names=["title"],
    output_field_names="bm25_sparse",
    function_type=FunctionType.BM25,
)
schema.add_function(bm25_function)


field_index_list = {
    "bm25_sparse": "BM25"
}
for field_name, index_type in field_index_list.items():
    create_vector_index(collection, field_name=field_name, index_type=index_type)
@Newxinchen Newxinchen added the kind/question A question to answer label Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question A question to answer
Projects
None yet
Development

No branches or pull requests

1 participant