Sonicclient Copyright Ahmed T. Youssef nim Sonic client TODO: check help.
1345 |Types
1347 |-
1348 |
1349 |
SonicChannel {...}{.pure.} = enum 1350 | Ingest, Search, Control
1351 | - 1352 | 1353 | 1354 | 1355 | 1356 |
Sonic = ref object of SonicBase[Socket]
1357 | - 1358 | 1359 | 1360 | 1361 | 1362 |
AsyncSonic = ref object of SonicBase[AsyncSocket]
1363 | - 1364 | 1365 | 1366 | 1367 | 1368 |
Procs
1371 |-
1372 |
1373 |
proc startSession(this: AsyncSonic): Future[void] {...}{.raises: [FutureError], 1374 | tags: [RootEffect].}
1375 | - 1376 | 1377 | 1378 | 1379 | 1380 |
proc startSession(this: Sonic): void {...}{.raises: [TimeoutError, OSError, SslError], tags: [ 1381 | ReadIOEffect, TimeEffect, WriteIOEffect].}
1382 | - 1383 | ## started. FIXME extract protocol bufsize 1384 | 1385 | 1386 | 1387 |
proc open(host = "localhost"; port = 1491; password = ""; channel: SonicChannel; 1388 | ssl = false; timeout = 0): Sonic {...}{.raises: [OSError, SslError, TimeoutError], tags: [ 1389 | ReadIOEffect, TimeEffect, WriteIOEffect].}
1390 | - 1391 | 1392 | 1393 | 1394 | 1395 |
proc openAsync(host = "localhost"; port = 1491; password = ""; channel: SonicChannel; 1396 | ssl = false; timeout = 0): Future[AsyncSonic] {...}{.raises: [FutureError], 1397 | tags: [RootEffect].}
1398 | - 1399 | Open an asynchronous connection to a Sonic server. 1400 | 1401 | 1402 | 1403 |
proc receiveManaged(this: AsyncSonic; size = 1): Future[string] {...}{. 1404 | raises: [FutureError], tags: [RootEffect].}
1405 | - 1406 | 1407 | 1408 | 1409 | 1410 |
proc receiveManaged(this: Sonic; size = 1): string {...}{. 1411 | raises: [TimeoutError, OSError, SslError, SonicServerError], 1412 | tags: [ReadIOEffect, TimeEffect].}
1413 | - 1414 | 1415 | 1416 | 1417 | 1418 |
proc execCommand(this: AsyncSonic; command: string; args: seq[string]): Future[string] {...}{. 1419 | raises: [FutureError], tags: [RootEffect].}
1420 | - 1421 | 1422 | 1423 | 1424 | 1425 |
proc execCommand(this: Sonic; command: string; args: seq[string]): string {...}{. 1426 | raises: [SslError, OSError, TimeoutError, SonicServerError], 1427 | tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
1428 | - 1429 | 1430 | 1431 | 1432 | 1433 |
proc execCommand(this: AsyncSonic; command: string): Future[string] {...}{. 1434 | raises: [FutureError], tags: [RootEffect].}
1435 | - 1436 | 1437 | 1438 | 1439 | 1440 |
proc execCommand(this: Sonic; command: string): string {...}{. 1441 | raises: [SslError, OSError, TimeoutError, SonicServerError], 1442 | tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
1443 | - 1444 | 1445 | 1446 | 1447 | 1448 |
proc ping(this: AsyncSonic): Future[bool] {...}{.raises: [FutureError], tags: [RootEffect].}
1449 | - 1450 | Send ping command to the server Returns: bool True if successfully reaching the server. 1451 | 1452 | 1453 | 1454 |
proc ping(this: Sonic): bool {...}{.raises: [SslError, OSError, TimeoutError, 1455 | SonicServerError], 1456 | tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
1457 | - 1458 | Send ping command to the server Returns: bool True if successfully reaching the server. 1459 | 1460 | 1461 | 1462 |
proc quit(this: AsyncSonic): Future[string] {...}{.raises: [FutureError], 1463 | tags: [RootEffect].}
1464 | - 1465 | Quit the channel and closes the connection. 1466 | 1467 | 1468 | 1469 |
proc quit(this: Sonic): string {...}{.raises: [SslError, OSError, TimeoutError, 1470 | SonicServerError], 1471 | tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
1472 | - 1473 | Quit the channel and closes the connection. 1474 | 1475 | 1476 | 1477 |
proc help(this: AsyncSonic; arg: string): Future[string] {...}{.raises: [FutureError], 1478 | tags: [RootEffect].}
1479 | - 1480 | Sends Help query. 1481 | 1482 | 1483 | 1484 |
proc help(this: Sonic; arg: string): string {...}{.raises: [SslError, OSError, TimeoutError, 1485 | SonicServerError], tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
1486 | - 1487 | Sends Help query. 1488 | 1489 | 1490 | 1491 |
proc push(this: AsyncSonic; collection, bucket, objectName, text: string; lang = ""): Future[ 1492 | bool] {...}{.raises: [FutureError], tags: [RootEffect].}
1493 | -
1494 |
- Push search data in the index 1495 |
- collection: index collection (ie. what you search in, eg. messages, products, etc.) 1496 |
- bucket: index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..) 1497 |
- objectName: object identifier that refers to an entity in an external database, where the searched object is stored (eg. you use Sonic to index CRM contacts by name; full CRM contact data is stored in a MySQL database; in this case the object identifier in Sonic will be the MySQL primary key for the CRM contact) 1498 |
- text: search text to be indexed can be a single word, or a longer text; within maximum length safety limits 1499 |
- lang: ISO language code 1500 |
- Returns: 1502 |
- bool True if search data are pushed in the index. 1503 |
1505 |
1509 |
1510 | proc push(this: Sonic; collection, bucket, objectName, text: string; lang = ""): bool {...}{. 1511 | raises: [SslError, OSError, TimeoutError, SonicServerError], 1512 | tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
1513 | -
1514 |
- Push search data in the index 1515 |
- collection: index collection (ie. what you search in, eg. messages, products, etc.) 1516 |
- bucket: index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..) 1517 |
- objectName: object identifier that refers to an entity in an external database, where the searched object is stored (eg. you use Sonic to index CRM contacts by name; full CRM contact data is stored in a MySQL database; in this case the object identifier in Sonic will be the MySQL primary key for the CRM contact) 1518 |
- text: search text to be indexed can be a single word, or a longer text; within maximum length safety limits 1519 |
- lang: ISO language code 1520 |
- Returns: 1522 |
- bool True if search data are pushed in the index. 1523 |
1525 |
1529 |
1530 | proc pop(this: AsyncSonic; collection, bucket, objectName, text: string): Future[int] {...}{. 1531 | raises: [FutureError], tags: [RootEffect].}
1532 | -
1533 |
- Pop search data from the index 1534 |
- collection: index collection (ie. what you search in, eg. messages, products, etc.) 1535 |
- bucket: index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..) 1536 |
- objectName: object identifier that refers to an entity in an external database, where the searched object is stored (eg. you use Sonic to index CRM contacts by name; full CRM contact data is stored in a MySQL database; in this case the object identifier in Sonic will be the MySQL primary key for the CRM contact) 1537 |
- text: search text to be indexed can be a single word, or a longer text; within maximum length safety limits 1538 |
- Returns: 1540 |
- int 1541 |
1543 |
1547 |
1548 | proc pop(this: Sonic; collection, bucket, objectName, text: string): int {...}{.raises: [ 1549 | SslError, OSError, TimeoutError, SonicServerError, OverflowError, ValueError], 1550 | tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
1551 | -
1552 |
- Pop search data from the index 1553 |
- collection: index collection (ie. what you search in, eg. messages, products, etc.) 1554 |
- bucket: index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..) 1555 |
- objectName: object identifier that refers to an entity in an external database, where the searched object is stored (eg. you use Sonic to index CRM contacts by name; full CRM contact data is stored in a MySQL database; in this case the object identifier in Sonic will be the MySQL primary key for the CRM contact) 1556 |
- text: search text to be indexed can be a single word, or a longer text; within maximum length safety limits 1557 |
- Returns: 1559 |
- int 1560 |
1562 |
1566 |
1567 | proc count(this: AsyncSonic; collection, bucket, objectName: string): Future[int] {...}{. 1568 | raises: [FutureError], tags: [RootEffect].}
1569 | -
1570 |
- Count indexed search data 1571 |
- collection: index collection (ie. what you search in, eg. messages, products, etc.) 1572 |
- bucket: index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..) 1573 |
- objectName: object identifier that refers to an entity in an external database, where the searched object is stored (eg. you use Sonic to index CRM contacts by name; full CRM contact data is stored in a MySQL database; in this case the object identifier in Sonic will be the MySQL primary key for the CRM contact) 1574 |
1576 |
Returns: int count of index search data.
1578 | 1579 | 1580 |
1581 |
1582 | proc count(this: Sonic; collection, bucket, objectName: string): int {...}{.raises: [ 1583 | OverflowError, ValueError, SslError, OSError, TimeoutError, SonicServerError], 1584 | tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
1585 | -
1586 |
- Count indexed search data 1587 |
- collection: index collection (ie. what you search in, eg. messages, products, etc.) 1588 |
- bucket: index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..) 1589 |
- objectName: object identifier that refers to an entity in an external database, where the searched object is stored (eg. you use Sonic to index CRM contacts by name; full CRM contact data is stored in a MySQL database; in this case the object identifier in Sonic will be the MySQL primary key for the CRM contact) 1590 |
1592 |
Returns: int count of index search data.
1594 | 1595 | 1596 |
1597 |
1598 | proc flushCollection(this: AsyncSonic; collection: string): Future[int] {...}{. 1599 | raises: [FutureError], tags: [RootEffect].}
1600 | -
1601 |
- Flush all indexed data from a collection 1602 |
- collection index collection (ie. what you search in, eg. messages, products, etc.) 1603 |
1608 |- Returns: 1605 |
- int number of flushed data 1606 |
1609 |
1613 |
1614 | proc flushCollection(this: Sonic; collection: string): int {...}{.raises: [OverflowError, 1615 | ValueError, SslError, OSError, TimeoutError, SonicServerError], 1616 | tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
1617 | -
1618 |
- Flush all indexed data from a collection 1619 |
- collection index collection (ie. what you search in, eg. messages, products, etc.) 1620 |
1625 |- Returns: 1622 |
- int number of flushed data 1623 |
1626 |
1630 |
1631 | proc flushBucket(this: AsyncSonic; collection, bucket: string): Future[int] {...}{. 1632 | raises: [FutureError], tags: [RootEffect].}
1633 | -
1634 |
- Flush all indexed data from a bucket in a collection 1635 |
- collection: index collection (ie. what you search in, eg. messages, products, etc.) 1636 |
- bucket: index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..) 1637 |
- Returns: 1639 |
- int number of flushed data 1640 |
1642 |
1646 |
1647 | proc flushBucket(this: Sonic; collection, bucket: string): int {...}{.raises: [OverflowError, 1648 | ValueError, SslError, OSError, TimeoutError, SonicServerError], 1649 | tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
1650 | -
1651 |
- Flush all indexed data from a bucket in a collection 1652 |
- collection: index collection (ie. what you search in, eg. messages, products, etc.) 1653 |
- bucket: index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..) 1654 |
- Returns: 1656 |
- int number of flushed data 1657 |
1659 |
1663 |
1664 | proc flushObject(this: AsyncSonic; collection, bucket, objectName: string): Future[int] {...}{. 1665 | raises: [FutureError], tags: [RootEffect].}
1666 | -
1667 |
- Flush all indexed data from an object in a bucket in collection 1668 |
- collection: index collection (ie. what you search in, eg. messages, products, etc.) 1669 |
- bucket: index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..) 1670 |
- objectName: object identifier that refers to an entity in an external database, where the searched object is stored (eg. you use Sonic to index CRM contacts by name; full CRM contact data is stored in a MySQL database; in this case the object identifier in Sonic will be the MySQL primary key for the CRM contact) 1671 |
- Returns: 1673 |
- int number of flushed data 1674 |
1676 |
1680 |
1681 | proc flushObject(this: Sonic; collection, bucket, objectName: string): int {...}{.raises: [ 1682 | OverflowError, ValueError, SslError, OSError, TimeoutError, SonicServerError], 1683 | tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
1684 | -
1685 |
- Flush all indexed data from an object in a bucket in collection 1686 |
- collection: index collection (ie. what you search in, eg. messages, products, etc.) 1687 |
- bucket: index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..) 1688 |
- objectName: object identifier that refers to an entity in an external database, where the searched object is stored (eg. you use Sonic to index CRM contacts by name; full CRM contact data is stored in a MySQL database; in this case the object identifier in Sonic will be the MySQL primary key for the CRM contact) 1689 |
- Returns: 1691 |
- int number of flushed data 1692 |
1694 |
1698 |
1699 | proc flush(this: AsyncSonic; collection: string; bucket = ""; objectName = ""): Future[int] {...}{. 1700 | raises: [FutureError], tags: [RootEffect].}
1701 | -
1702 |
- Flush indexed data in a collection, bucket, or in an object. 1703 |
- collection: index collection (ie. what you search in, eg. messages, products, etc.) 1704 |
- bucket: index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..) 1705 |
- objectName: object identifier that refers to an entity in an external database, where the searched object is stored (eg. you use Sonic to index CRM contacts by name; full CRM contact data is stored in a MySQL database; in this case the object identifier in Sonic will be the MySQL primary key for the CRM contact) 1706 |
- Returns: 1708 |
- int number of flushed data 1709 |
1711 |
1715 |
1716 | proc flush(this: Sonic; collection: string; bucket = ""; objectName = ""): int {...}{.raises: [ 1717 | OverflowError, ValueError, SslError, OSError, TimeoutError, SonicServerError], 1718 | tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
1719 | -
1720 |
- Flush indexed data in a collection, bucket, or in an object. 1721 |
- collection: index collection (ie. what you search in, eg. messages, products, etc.) 1722 |
- bucket: index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..) 1723 |
- objectName: object identifier that refers to an entity in an external database, where the searched object is stored (eg. you use Sonic to index CRM contacts by name; full CRM contact data is stored in a MySQL database; in this case the object identifier in Sonic will be the MySQL primary key for the CRM contact) 1724 |
- Returns: 1726 |
- int number of flushed data 1727 |
1729 |
1733 |
1734 | proc query(this: AsyncSonic; collection, bucket, terms: string; limit = 10; 1735 | offset: int = 0; lang = ""): Future[seq[string]] {...}{.raises: [FutureError], 1736 | tags: [RootEffect].}
1737 | -
1738 |
- Query the database 1739 |
- collection index collection (ie. what you search in, eg. messages, products, etc.) 1740 |
- bucket index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..) 1741 |
- terms text for search terms 1742 |
- limit a positive integer number; set within allowed maximum & minimum limits 1743 |
- offset a positive integer number; set within allowed maximum & minimum limits 1744 |
- lang an ISO 639-3 locale code eg. eng for English (if set, the locale must be a valid ISO 639-3 code; if not set, the locale will be guessed from text). 1745 |
- Returns: 1747 |
- list list of objects ids. 1748 |
1750 |
1754 |
1755 | proc query(this: Sonic; collection, bucket, terms: string; limit = 10; offset: int = 0; 1756 | lang = ""): seq[string] {...}{.raises: [SslError, OSError, TimeoutError, 1757 | SonicServerError], 1758 | tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
1759 | -
1760 |
- Query the database 1761 |
- collection index collection (ie. what you search in, eg. messages, products, etc.) 1762 |
- bucket index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..) 1763 |
- terms text for search terms 1764 |
- limit a positive integer number; set within allowed maximum & minimum limits 1765 |
- offset a positive integer number; set within allowed maximum & minimum limits 1766 |
- lang an ISO 639-3 locale code eg. eng for English (if set, the locale must be a valid ISO 639-3 code; if not set, the locale will be guessed from text). 1767 |
- Returns: 1769 |
- list list of objects ids. 1770 |
1772 |
1776 |
1777 | proc suggest(this: AsyncSonic; collection, bucket, word: string; limit = 10): Future[ 1778 | seq[string]] {...}{.raises: [FutureError], tags: [RootEffect].}
1779 | -
1780 |
- auto-completes word. 1781 |
- collection index collection (ie. what you search in, eg. messages, products, etc.) 1782 |
- bucket index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..) 1783 |
- word word to autocomplete 1784 |
- limit a positive integer number; set within allowed maximum & minimum limits (procault: {None}) 1785 |
- Returns: 1787 |
- list list of suggested words. 1788 |
1790 |
1794 |
1795 | proc suggest(this: Sonic; collection, bucket, word: string; limit = 10): seq[string] {...}{. 1796 | raises: [SslError, OSError, TimeoutError, SonicServerError], 1797 | tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
1798 | -
1799 |
- auto-completes word. 1800 |
- collection index collection (ie. what you search in, eg. messages, products, etc.) 1801 |
- bucket index bucket name (ie. user-specific search classifier in the collection if you have any eg. user-1, user-2, .., otherwise use a common bucket name eg. generic, procault, common, ..) 1802 |
- word word to autocomplete 1803 |
- limit a positive integer number; set within allowed maximum & minimum limits (procault: {None}) 1804 |
- Returns: 1806 |
- list list of suggested words. 1807 |
1809 |
1813 |
1814 | proc trigger(this: AsyncSonic; action = ""): Future[string] {...}{.raises: [FutureError], 1815 | tags: [RootEffect].}
1816 | -
1817 |
- Trigger an action 1818 |
- action text for action 1819 |
1823 |
1824 | proc trigger(this: Sonic; action = ""): string {...}{. 1825 | raises: [SslError, OSError, TimeoutError, SonicServerError], 1826 | tags: [WriteIOEffect, ReadIOEffect, TimeEffect].}
1827 | -
1828 |
- Trigger an action 1829 |
- action text for action 1830 |
1834 |
1835 |