|
16 | 16 | StartIndexingOperation, |
17 | 17 | StopIndexOperation, |
18 | 18 | GetIndexesOperation, |
19 | | - GetIndexStatisticsOperation, SetIndexesLockOperation, SetIndexesPriorityOperation, |
| 19 | + GetIndexStatisticsOperation, |
| 20 | + SetIndexesLockOperation, |
| 21 | + SetIndexesPriorityOperation, |
| 22 | + GetTermsOperation, |
| 23 | +) |
| 24 | +from ravendb.documents.indexes.definitions import ( |
| 25 | + FieldIndexing, |
| 26 | + FieldStorage, |
| 27 | + IndexLockMode, |
| 28 | + IndexRunningStatus, |
| 29 | + IndexPriority, |
20 | 30 | ) |
21 | | -from ravendb.documents.indexes.definitions import FieldIndexing, FieldStorage, IndexLockMode, IndexRunningStatus, \ |
22 | | - IndexPriority |
23 | 31 | from ravendb.documents.indexes.abstract_index_creation_tasks import AbstractIndexCreationTask |
24 | 32 | from ravendb.infrastructure.entities import User, Post |
25 | 33 | from ravendb.tests.test_base import TestBase |
@@ -271,9 +279,37 @@ def test_set_lock_mode_and_set_priority(self): |
271 | 279 | self.assertEqual(stats.priority, IndexPriority.NORMAL) |
272 | 280 |
|
273 | 281 | self.store.maintenance.send(SetIndexesLockOperation(IndexLockMode.LOCKED_IGNORE, index.name)) |
274 | | - self.store.maintenance.send(SetIndexesPriorityOperation(IndexPriority.LOW,index.name )) |
| 282 | + self.store.maintenance.send(SetIndexesPriorityOperation(IndexPriority.LOW, index.name)) |
275 | 283 |
|
276 | 284 | stats = self.store.maintenance.send(GetIndexStatisticsOperation(index.name)) |
277 | 285 |
|
278 | 286 | self.assertEqual(IndexLockMode.LOCKED_IGNORE, stats.lock_mode) |
279 | 287 | self.assertEqual(IndexPriority.LOW, stats.priority) |
| 288 | + |
| 289 | + def test_get_terms(self): |
| 290 | + with self.store.open_session() as session: |
| 291 | + session.store(User(name="Fitzchak")) |
| 292 | + session.store(User(name="Arek")) |
| 293 | + session.save_changes() |
| 294 | + |
| 295 | + with self.store.open_session() as session: |
| 296 | + stats: Optional[QueryStatistics] = None |
| 297 | + |
| 298 | + def _stats(s: QueryStatistics): |
| 299 | + nonlocal stats |
| 300 | + stats = s |
| 301 | + |
| 302 | + users = list( |
| 303 | + session.query(object_type=User) |
| 304 | + .wait_for_non_stale_results() |
| 305 | + .statistics(_stats) |
| 306 | + .where_equals("name", "Arek") |
| 307 | + ) |
| 308 | + index_name = stats.index_name |
| 309 | + |
| 310 | + terms = self.store.maintenance.send(GetTermsOperation(index_name, "name", None, 128)) |
| 311 | + |
| 312 | + self.assertEqual(2, len(terms)) |
| 313 | + |
| 314 | + self.assertIn("arek", terms) |
| 315 | + self.assertIn("fitzchak", terms) |
0 commit comments