|
8 | 8 | FieldTermVector,
|
9 | 9 | IndexDefinition,
|
10 | 10 | IndexSourceType,
|
| 11 | + IndexFieldOptions, |
| 12 | + IndexType, |
11 | 13 | )
|
12 | 14 | from ravendb.documents.indexes.index_creation import AbstractIndexCreationTaskBase, AbstractIndexDefinitionBuilder
|
13 | 15 | from ravendb.documents.indexes.spatial.configuration import SpatialOptions, SpatialOptionsFactory
|
@@ -119,3 +121,73 @@ def create_index_definition(self) -> CountersIndexDefinition:
|
119 | 121 | index_definition_builder.deployment_mode = self.deployment_mode
|
120 | 122 |
|
121 | 123 | return index_definition_builder.to_index_definition(self.conventions)
|
| 124 | + |
| 125 | + |
| 126 | +class AbstractJavaScriptCountersIndexCreationTask(AbstractIndexCreationTaskBase[CountersIndexDefinition]): |
| 127 | + def __init__(self): |
| 128 | + super(AbstractJavaScriptCountersIndexCreationTask, self).__init__() |
| 129 | + self._definition = CountersIndexDefinition() |
| 130 | + |
| 131 | + @property |
| 132 | + def maps(self) -> Set[str]: |
| 133 | + return self._definition.maps |
| 134 | + |
| 135 | + @maps.setter |
| 136 | + def maps(self, value: Set[str]): |
| 137 | + self._definition.maps = value |
| 138 | + |
| 139 | + @property |
| 140 | + def fields(self) -> Dict[str, IndexFieldOptions]: |
| 141 | + return self._definition.fields |
| 142 | + |
| 143 | + @fields.setter |
| 144 | + def fields(self, value: Dict[str, IndexFieldOptions]): |
| 145 | + self._definition.fields = value |
| 146 | + |
| 147 | + @property |
| 148 | + def reduce(self) -> str: |
| 149 | + return self._definition.reduce |
| 150 | + |
| 151 | + @reduce.setter |
| 152 | + def reduce(self, value: Dict[str, IndexFieldOptions]): |
| 153 | + self._definition.reduce = value |
| 154 | + |
| 155 | + @property |
| 156 | + def is_map_reduce(self) -> bool: |
| 157 | + return self.reduce is not None |
| 158 | + |
| 159 | + @property |
| 160 | + def output_reduce_to_collection(self) -> str: |
| 161 | + return self._definition.output_reduce_to_collection |
| 162 | + |
| 163 | + @output_reduce_to_collection.setter |
| 164 | + def output_reduce_to_collection(self, value: Dict[str, IndexFieldOptions]): |
| 165 | + self._definition.output_reduce_to_collection = value |
| 166 | + |
| 167 | + @property |
| 168 | + def pattern_references_collection_name(self) -> str: |
| 169 | + return self._definition.pattern_references_collection_name |
| 170 | + |
| 171 | + @pattern_references_collection_name.setter |
| 172 | + def pattern_references_collection_name(self, value: Dict[str, IndexFieldOptions]): |
| 173 | + self._definition.pattern_references_collection_name = value |
| 174 | + |
| 175 | + @property |
| 176 | + def pattern_for_output_reduce_to_collection_references(self) -> str: |
| 177 | + return self._definition.pattern_for_output_reduce_to_collection_references |
| 178 | + |
| 179 | + @pattern_for_output_reduce_to_collection_references.setter |
| 180 | + def pattern_for_output_reduce_to_collection_references(self, value: Dict[str, IndexFieldOptions]): |
| 181 | + self._definition.pattern_for_output_reduce_to_collection_references = value |
| 182 | + |
| 183 | + def create_index_definition(self) -> CountersIndexDefinition: |
| 184 | + self._definition.name = self.index_name |
| 185 | + self._definition.type = IndexType.JAVA_SCRIPT_MAP_REDUCE if self.is_map_reduce else IndexType.JAVA_SCRIPT_MAP |
| 186 | + self._definition.additional_sources = self.additional_sources or {} |
| 187 | + self._definition.additional_assemblies = self.additional_assemblies or set() |
| 188 | + self._definition.configuration = self.configuration |
| 189 | + self._definition.lock_mode = self.lock_mode |
| 190 | + self._definition.priority = self.priority |
| 191 | + self._definition.state = self.state |
| 192 | + self._definition.deployment_mode = self.deployment_mode |
| 193 | + return self._definition |
0 commit comments