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

Thomasht86/support multiple index values #1032

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
43 changes: 43 additions & 0 deletions tests/unit/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -1963,6 +1963,49 @@ def test_document_expiry(self):
self.assertTrue(validate_services(application_package.services_to_text))


class TestPredicateField(unittest.TestCase):
def setUp(self):
self.app_package = ApplicationPackage(name="predicatetest")

# Add a document with a predicate field
self.app_package.schema.add_fields(
Field(name="id", type="string", indexing=["attribute", "summary"]),
Field(
name="predicate_field",
type="predicate",
indexing=["attribute"],
index={
"arity": 2,
"lower-bound": 3,
"upper-bound": 200,
"dense-posting-list-threshold": 0.25,
},
),
)

def test_predicate_field_schema(self):
expected_result = """schema predicatetest {
document predicatetest {
field id type string {
indexing: attribute | summary
}
field predicate_field type predicate {
indexing: attribute
index {
arity: 2
lower-bound: 3
upper-bound: 200
dense-posting-list-threshold: 0.25
}
}
}
}"""
print()
print(self.app_package.schema.schema_to_text)
print()
print(expected_result)
self.assertEqual(self.app_package.schema.schema_to_text, expected_result)

class TestRankProfileCustomSettings(unittest.TestCase):
def test_rank_profile_with_filter_and_weakand(self):
# Create a minimal schema with a dummy document to allow rank profile rendering.
Expand Down
8 changes: 8 additions & 0 deletions vespa/templates/macros.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@ field {{ field.name }} type {{ field.type }} {
indexing: {{ field.indexing_to_text }}
{% endif %}
{% if field.index %}
{% if field.index is mapping %}
index {
{% for key, value in field.index.items() %}
{{ key }}: {{ value }}
{% endfor %}
}
{% else %}
index: {{ field.index }}
{% endif %}
{% endif %}
{% if field.ann or field.attribute %}
attribute {
{% if field.ann %}
Expand Down
8 changes: 8 additions & 0 deletions vespa/templates/schema.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@ schema {{ schema_name }}{% if schema.inherits %} inherits {{ schema.inherits }}{
indexing: {{ field.indexing_to_text }}
{% endif %}
{% if field.index %}
{% if field.index is mapping %}
index {
{% for key, value in field.index.items() %}
{{ key }}: {{ value }}
{% endfor %}
}
{% else %}
index: {{ field.index }}
{% endif %}
{% endif %}
{% if field.ann or field.attribute %}
attribute {
{% if field.ann %}
Expand Down