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

[ENHANCEMENT] argilla-server: add search support for custom fields #5461

16 changes: 12 additions & 4 deletions argilla-server/src/argilla_server/search_engine/commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from elasticsearch8 import AsyncElasticsearch
from opensearchpy import AsyncOpenSearch

from argilla_server.enums import FieldType, MetadataPropertyType, RecordSortField, ResponseStatusFilter, SimilarityOrder
from argilla_server.enums import MetadataPropertyType, RecordSortField, ResponseStatusFilter, SimilarityOrder
from argilla_server.models import (
Dataset,
Field,
Expand Down Expand Up @@ -165,7 +165,7 @@

frascuchon marked this conversation as resolved.
Show resolved Hide resolved
if field.is_text:
return {es_field_for_record_field(field.name): {"type": "text"}}
if field.is_chat:
elif field.is_chat:
es_field = {
"type": "object",
"properties": {
Expand All @@ -174,7 +174,15 @@
},
}
return {es_field_for_record_field(field.name): es_field}
elif field.is_image or field.is_custom:
elif field.is_custom:
return {

Check warning on line 178 in argilla-server/src/argilla_server/search_engine/commons.py

View check run for this annotation

Codecov / codecov/patch

argilla-server/src/argilla_server/search_engine/commons.py#L178

Added line #L178 was not covered by tests
es_field_for_record_field(field.name): {
"type": "object",
"dynamic": True,
"properties": {},
}
}
elif field.is_image:
return {
es_field_for_record_field(field.name): {
"type": "object",
Expand Down Expand Up @@ -652,7 +660,7 @@
if field is None:
raise Exception(f"Field {text.field} not found in dataset {dataset.id}")

if field.is_chat:
if field.is_chat or field.is_custom:
field_name = f"{text.field}.*"
else:
field_name = text.field
Expand Down
Loading