Skip to content

Commit b1264ae

Browse files
committed
DRY - use macros in schemas
1 parent 1b43841 commit b1264ae

1 file changed

Lines changed: 1 addition & 86 deletions

File tree

vespa/templates/schema.txt

Lines changed: 1 addition & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -12,92 +12,7 @@ schema {{ schema_name }}{% if schema.inherits %} inherits {{ schema.inherits }}{
1212
{% for struct in document.structs %}
1313
struct {{struct.name}} {
1414
{% for field in struct.fields %}
15-
field {{ field.name }} type {{ field.type }} {
16-
{% if field.indexing %}
17-
indexing: {{ field.indexing_to_text }}
18-
{% endif %}
19-
{% if field.index_configurations %}
20-
{% if field.use_simple_index_syntax %}
21-
index: {{ field.index_configurations[0] }}
22-
{% else %}
23-
index {
24-
{% for index_config in field.index_configurations %}
25-
{% if index_config is mapping %}
26-
{% for key, value in index_config.items() %}
27-
{% if value is none %}
28-
{{ key }}
29-
{% else %}
30-
{{ key }}: {{ value }}
31-
{% endif %}
32-
{% endfor %}
33-
{% else %}
34-
{{ index_config }}
35-
{% endif %}
36-
{% endfor %}
37-
}
38-
{% endif %}
39-
{% endif %}
40-
{% if field.ann or field.attribute %}
41-
attribute {
42-
{% if field.ann %}
43-
distance-metric: {{ field.ann.distance_metric }}
44-
{% endif %}
45-
{% if field.attribute %}
46-
{% for attribute in field.attribute %}
47-
{{ attribute }}
48-
{% endfor %}
49-
{% endif %}
50-
}
51-
{% endif %}
52-
{% if field.ann %}
53-
index {
54-
hnsw {
55-
max-links-per-node: {{ field.ann.max_links_per_node }}
56-
neighbors-to-explore-at-insert: {{ field.ann.neighbors_to_explore_at_insert }}
57-
}
58-
}
59-
{% endif %}
60-
{% if field.match %}
61-
match {
62-
{% for match in field.match %}
63-
{% if match is string %}
64-
{{ match }}
65-
{% else %}
66-
{{ match.0 }}: {{ match.1 }}
67-
{% endif %}
68-
{% endfor %}
69-
}
70-
{% endif %}
71-
{% if field.weight %}
72-
weight: {{ field.weight }}
73-
{% endif %}
74-
{% if field.bolding %}
75-
bolding: on
76-
{% endif %}
77-
{% if field.summary %}
78-
{% for line in field.summary.as_lines %}
79-
{{ line }}
80-
{% endfor %}
81-
{% endif %}
82-
{% if field.stemming %}
83-
stemming: {{ field.stemming }}
84-
{% endif %}
85-
{% if field.rank %}
86-
rank: {{ field.rank }}
87-
{% endif %}
88-
{% if field.query_command %}
89-
query-command: {{ field.query_command }}
90-
{% endif %}
91-
{% if field.alias %}
92-
{% for alias in field.alias %}
93-
{% if ':' in alias %}
94-
alias {{ alias.split(':')[0].strip(' ') }}: {{ alias.split(':')[1].strip(' ') }}
95-
{% else %}
96-
alias: {{ alias }}
97-
{% endif %}
98-
{% endfor %}
99-
{% endif %}
100-
}
15+
{{ macros.field(field, 12)[1:] }}
10116
{% endfor %}
10217
}
10318
{% endfor %}

0 commit comments

Comments
 (0)