1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070
|
# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
import typing as t
from elastic_transport import HeadApiResponse, ObjectApiResponse
from ._base import NamespacedClient
from .utils import (
SKIP_IN_PATH,
Stability,
_quote,
_rewrite_parameters,
_stability_warning,
)
class IndicesClient(NamespacedClient):
@_rewrite_parameters()
async def add_block(
self,
*,
index: str,
block: t.Union[str, t.Literal["metadata", "read", "read_only", "write"]],
allow_no_indices: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
ignore_unavailable: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Add an index block.</p>
<p>Add an index block to an index.
Index blocks limit the operations allowed on an index by blocking specific operation types.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-add-block>`_
:param index: A comma-separated list or wildcard expression of index names used
to limit the request. By default, you must explicitly name the indices you
are adding blocks to. To allow the adding of blocks to indices with `_all`,
`*`, or other wildcard expressions, change the `action.destructive_requires_name`
setting to `false`. You can update this setting in the `elasticsearch.yml`
file or by using the cluster update settings API.
:param block: The block type to add to the index.
:param allow_no_indices: If `false`, the request returns an error if any wildcard
expression, index alias, or `_all` value targets only missing or closed indices.
This behavior applies even if the request targets other open indices. For
example, a request targeting `foo*,bar*` returns an error if an index starts
with `foo` but no index starts with `bar`.
:param expand_wildcards: The type of index that wildcard patterns can match.
If the request can target data streams, this argument determines whether
wildcard expressions match hidden data streams. It supports comma-separated
values, such as `open,hidden`.
:param ignore_unavailable: If `false`, the request returns an error if it targets
a missing or closed index.
:param master_timeout: The period to wait for the master node. If the master
node is not available before the timeout expires, the request fails and returns
an error. It can also be set to `-1` to indicate that the request should
never timeout.
:param timeout: The period to wait for a response from all relevant nodes in
the cluster after updating the cluster metadata. If no response is received
before the timeout expires, the cluster metadata update still applies but
the response will indicate that it was not completely acknowledged. It can
also be set to `-1` to indicate that the request should never timeout.
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'index'")
if block in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'block'")
__path_parts: t.Dict[str, str] = {
"index": _quote(index),
"block": _quote(block),
}
__path = f'/{__path_parts["index"]}/_block/{__path_parts["block"]}'
__query: t.Dict[str, t.Any] = {}
if allow_no_indices is not None:
__query["allow_no_indices"] = allow_no_indices
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if ignore_unavailable is not None:
__query["ignore_unavailable"] = ignore_unavailable
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
if timeout is not None:
__query["timeout"] = timeout
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"PUT",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.add_block",
path_parts=__path_parts,
)
@_rewrite_parameters(
body_fields=(
"analyzer",
"attributes",
"char_filter",
"explain",
"field",
"filter",
"normalizer",
"text",
"tokenizer",
),
)
async def analyze(
self,
*,
index: t.Optional[str] = None,
analyzer: t.Optional[str] = None,
attributes: t.Optional[t.Sequence[str]] = None,
char_filter: t.Optional[t.Sequence[t.Union[str, t.Mapping[str, t.Any]]]] = None,
error_trace: t.Optional[bool] = None,
explain: t.Optional[bool] = None,
field: t.Optional[str] = None,
filter: t.Optional[t.Sequence[t.Union[str, t.Mapping[str, t.Any]]]] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
normalizer: t.Optional[str] = None,
pretty: t.Optional[bool] = None,
text: t.Optional[t.Union[str, t.Sequence[str]]] = None,
tokenizer: t.Optional[t.Union[str, t.Mapping[str, t.Any]]] = None,
body: t.Optional[t.Dict[str, t.Any]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Get tokens from text analysis.
The analyze API performs analysis on a text string and returns the resulting tokens.</p>
<p>Generating excessive amount of tokens may cause a node to run out of memory.
The <code>index.analyze.max_token_count</code> setting enables you to limit the number of tokens that can be produced.
If more than this limit of tokens gets generated, an error occurs.
The <code>_analyze</code> endpoint without a specified index will always use <code>10000</code> as its limit.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-analyze>`_
:param index: Index used to derive the analyzer. If specified, the `analyzer`
or field parameter overrides this value. If no index is specified or the
index does not have a default analyzer, the analyze API uses the standard
analyzer.
:param analyzer: The name of the analyzer that should be applied to the provided
`text`. This could be a built-in analyzer, or an analyzer that’s been configured
in the index.
:param attributes: Array of token attributes used to filter the output of the
`explain` parameter.
:param char_filter: Array of character filters used to preprocess characters
before the tokenizer.
:param explain: If `true`, the response includes token attributes and additional
details.
:param field: Field used to derive the analyzer. To use this parameter, you must
specify an index. If specified, the `analyzer` parameter overrides this value.
:param filter: Array of token filters used to apply after the tokenizer.
:param normalizer: Normalizer to use to convert text into a single token.
:param text: Text to analyze. If an array of strings is provided, it is analyzed
as a multi-value field.
:param tokenizer: Tokenizer to use to convert text into tokens.
"""
__path_parts: t.Dict[str, str]
if index not in SKIP_IN_PATH:
__path_parts = {"index": _quote(index)}
__path = f'/{__path_parts["index"]}/_analyze'
else:
__path_parts = {}
__path = "/_analyze"
__query: t.Dict[str, t.Any] = {}
__body: t.Dict[str, t.Any] = body if body is not None else {}
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if pretty is not None:
__query["pretty"] = pretty
if not __body:
if analyzer is not None:
__body["analyzer"] = analyzer
if attributes is not None:
__body["attributes"] = attributes
if char_filter is not None:
__body["char_filter"] = char_filter
if explain is not None:
__body["explain"] = explain
if field is not None:
__body["field"] = field
if filter is not None:
__body["filter"] = filter
if normalizer is not None:
__body["normalizer"] = normalizer
if text is not None:
__body["text"] = text
if tokenizer is not None:
__body["tokenizer"] = tokenizer
if not __body:
__body = None # type: ignore[assignment]
__headers = {"accept": "application/json"}
if __body is not None:
__headers["content-type"] = "application/json"
return await self.perform_request( # type: ignore[return-value]
"POST",
__path,
params=__query,
headers=__headers,
body=__body,
endpoint_id="indices.analyze",
path_parts=__path_parts,
)
@_rewrite_parameters()
@_stability_warning(Stability.EXPERIMENTAL)
async def cancel_migrate_reindex(
self,
*,
index: t.Union[str, t.Sequence[str]],
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
pretty: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Cancel a migration reindex operation.</p>
<p>Cancel a migration reindex attempt for a data stream or index.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-cancel-migrate-reindex>`_
:param index: The index or data stream name
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'index'")
__path_parts: t.Dict[str, str] = {"index": _quote(index)}
__path = f'/_migration/reindex/{__path_parts["index"]}/_cancel'
__query: t.Dict[str, t.Any] = {}
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if pretty is not None:
__query["pretty"] = pretty
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"POST",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.cancel_migrate_reindex",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def clear_cache(
self,
*,
index: t.Optional[t.Union[str, t.Sequence[str]]] = None,
allow_no_indices: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
fielddata: t.Optional[bool] = None,
fields: t.Optional[t.Union[str, t.Sequence[str]]] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
ignore_unavailable: t.Optional[bool] = None,
pretty: t.Optional[bool] = None,
query: t.Optional[bool] = None,
request: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Clear the cache.
Clear the cache of one or more indices.
For data streams, the API clears the caches of the stream's backing indices.</p>
<p>By default, the clear cache API clears all caches.
To clear only specific caches, use the <code>fielddata</code>, <code>query</code>, or <code>request</code> parameters.
To clear the cache only of specific fields, use the <code>fields</code> parameter.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-clear-cache>`_
:param index: Comma-separated list of data streams, indices, and aliases used
to limit the request. Supports wildcards (`*`). To target all data streams
and indices, omit this parameter or use `*` or `_all`.
:param allow_no_indices: If `false`, the request returns an error if any wildcard
expression, index alias, or `_all` value targets only missing or closed indices.
This behavior applies even if the request targets other open indices.
:param expand_wildcards: Type of index that wildcard patterns can match. If the
request can target data streams, this argument determines whether wildcard
expressions match hidden data streams. Supports comma-separated values, such
as `open,hidden`.
:param fielddata: If `true`, clears the fields cache. Use the `fields` parameter
to clear the cache of specific fields only.
:param fields: Comma-separated list of field names used to limit the `fielddata`
parameter.
:param ignore_unavailable: If `false`, the request returns an error if it targets
a missing or closed index.
:param query: If `true`, clears the query cache.
:param request: If `true`, clears the request cache.
"""
__path_parts: t.Dict[str, str]
if index not in SKIP_IN_PATH:
__path_parts = {"index": _quote(index)}
__path = f'/{__path_parts["index"]}/_cache/clear'
else:
__path_parts = {}
__path = "/_cache/clear"
__query: t.Dict[str, t.Any] = {}
if allow_no_indices is not None:
__query["allow_no_indices"] = allow_no_indices
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if fielddata is not None:
__query["fielddata"] = fielddata
if fields is not None:
__query["fields"] = fields
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if ignore_unavailable is not None:
__query["ignore_unavailable"] = ignore_unavailable
if pretty is not None:
__query["pretty"] = pretty
if query is not None:
__query["query"] = query
if request is not None:
__query["request"] = request
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"POST",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.clear_cache",
path_parts=__path_parts,
)
@_rewrite_parameters(
body_fields=("aliases", "settings"),
)
async def clone(
self,
*,
index: str,
target: str,
aliases: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
settings: t.Optional[t.Mapping[str, t.Any]] = None,
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
wait_for_active_shards: t.Optional[
t.Union[int, t.Union[str, t.Literal["all", "index-setting"]]]
] = None,
body: t.Optional[t.Dict[str, t.Any]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Clone an index.
Clone an existing index into a new index.
Each original primary shard is cloned into a new primary shard in the new index.</p>
<p>IMPORTANT: Elasticsearch does not apply index templates to the resulting index.
The API also does not copy index metadata from the original index.
Index metadata includes aliases, index lifecycle management phase definitions, and cross-cluster replication (CCR) follower information.
For example, if you clone a CCR follower index, the resulting clone will not be a follower index.</p>
<p>The clone API copies most index settings from the source index to the resulting index, with the exception of <code>index.number_of_replicas</code> and <code>index.auto_expand_replicas</code>.
To set the number of replicas in the resulting index, configure these settings in the clone request.</p>
<p>Cloning works as follows:</p>
<ul>
<li>First, it creates a new target index with the same definition as the source index.</li>
<li>Then it hard-links segments from the source index into the target index. If the file system does not support hard-linking, all segments are copied into the new index, which is a much more time consuming process.</li>
<li>Finally, it recovers the target index as though it were a closed index which had just been re-opened.</li>
</ul>
<p>IMPORTANT: Indices can only be cloned if they meet the following requirements:</p>
<ul>
<li>The index must be marked as read-only and have a cluster health status of green.</li>
<li>The target index must not exist.</li>
<li>The source index must have the same number of primary shards as the target index.</li>
<li>The node handling the clone process must have sufficient free disk space to accommodate a second copy of the existing index.</li>
</ul>
<p>The current write index on a data stream cannot be cloned.
In order to clone the current write index, the data stream must first be rolled over so that a new write index is created and then the previous write index can be cloned.</p>
<p>NOTE: Mappings cannot be specified in the <code>_clone</code> request. The mappings of the source index will be used for the target index.</p>
<p><strong>Monitor the cloning process</strong></p>
<p>The cloning process can be monitored with the cat recovery API or the cluster health API can be used to wait until all primary shards have been allocated by setting the <code>wait_for_status</code> parameter to <code>yellow</code>.</p>
<p>The <code>_clone</code> API returns as soon as the target index has been added to the cluster state, before any shards have been allocated.
At this point, all shards are in the state unassigned.
If, for any reason, the target index can't be allocated, its primary shard will remain unassigned until it can be allocated on that node.</p>
<p>Once the primary shard is allocated, it moves to state initializing, and the clone process begins.
When the clone operation completes, the shard will become active.
At that point, Elasticsearch will try to allocate any replicas and may decide to relocate the primary shard to another node.</p>
<p><strong>Wait for active shards</strong></p>
<p>Because the clone operation creates a new index to clone the shards to, the wait for active shards setting on index creation applies to the clone index action as well.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-clone>`_
:param index: Name of the source index to clone.
:param target: Name of the target index to create.
:param aliases: Aliases for the resulting index.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
:param settings: Configuration options for the target index.
:param timeout: Period to wait for a response. If no response is received before
the timeout expires, the request fails and returns an error.
:param wait_for_active_shards: The number of shard copies that must be active
before proceeding with the operation. Set to `all` or any positive integer
up to the total number of shards in the index (`number_of_replicas+1`).
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'index'")
if target in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'target'")
__path_parts: t.Dict[str, str] = {
"index": _quote(index),
"target": _quote(target),
}
__path = f'/{__path_parts["index"]}/_clone/{__path_parts["target"]}'
__query: t.Dict[str, t.Any] = {}
__body: t.Dict[str, t.Any] = body if body is not None else {}
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
if timeout is not None:
__query["timeout"] = timeout
if wait_for_active_shards is not None:
__query["wait_for_active_shards"] = wait_for_active_shards
if not __body:
if aliases is not None:
__body["aliases"] = aliases
if settings is not None:
__body["settings"] = settings
if not __body:
__body = None # type: ignore[assignment]
__headers = {"accept": "application/json"}
if __body is not None:
__headers["content-type"] = "application/json"
return await self.perform_request( # type: ignore[return-value]
"PUT",
__path,
params=__query,
headers=__headers,
body=__body,
endpoint_id="indices.clone",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def close(
self,
*,
index: t.Union[str, t.Sequence[str]],
allow_no_indices: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
ignore_unavailable: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
wait_for_active_shards: t.Optional[
t.Union[int, t.Union[str, t.Literal["all", "index-setting"]]]
] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Close an index.
A closed index is blocked for read or write operations and does not allow all operations that opened indices allow.
It is not possible to index documents or to search for documents in a closed index.
Closed indices do not have to maintain internal data structures for indexing or searching documents, which results in a smaller overhead on the cluster.</p>
<p>When opening or closing an index, the master node is responsible for restarting the index shards to reflect the new state of the index.
The shards will then go through the normal recovery process.
The data of opened and closed indices is automatically replicated by the cluster to ensure that enough shard copies are safely kept around at all times.</p>
<p>You can open and close multiple indices.
An error is thrown if the request explicitly refers to a missing index.
This behaviour can be turned off using the <code>ignore_unavailable=true</code> parameter.</p>
<p>By default, you must explicitly name the indices you are opening or closing.
To open or close indices with <code>_all</code>, <code>*</code>, or other wildcard expressions, change the<code> action.destructive_requires_name</code> setting to <code>false</code>. This setting can also be changed with the cluster update settings API.</p>
<p>Closed indices consume a significant amount of disk-space which can cause problems in managed environments.
Closing indices can be turned off with the cluster settings API by setting <code>cluster.indices.close.enable</code> to <code>false</code>.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-close>`_
:param index: Comma-separated list or wildcard expression of index names used
to limit the request.
:param allow_no_indices: If `false`, the request returns an error if any wildcard
expression, index alias, or `_all` value targets only missing or closed indices.
This behavior applies even if the request targets other open indices.
:param expand_wildcards: Type of index that wildcard patterns can match. If the
request can target data streams, this argument determines whether wildcard
expressions match hidden data streams. Supports comma-separated values, such
as `open,hidden`.
:param ignore_unavailable: If `false`, the request returns an error if it targets
a missing or closed index.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
:param timeout: Period to wait for a response. If no response is received before
the timeout expires, the request fails and returns an error.
:param wait_for_active_shards: The number of shard copies that must be active
before proceeding with the operation. Set to `all` or any positive integer
up to the total number of shards in the index (`number_of_replicas+1`).
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'index'")
__path_parts: t.Dict[str, str] = {"index": _quote(index)}
__path = f'/{__path_parts["index"]}/_close'
__query: t.Dict[str, t.Any] = {}
if allow_no_indices is not None:
__query["allow_no_indices"] = allow_no_indices
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if ignore_unavailable is not None:
__query["ignore_unavailable"] = ignore_unavailable
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
if timeout is not None:
__query["timeout"] = timeout
if wait_for_active_shards is not None:
__query["wait_for_active_shards"] = wait_for_active_shards
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"POST",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.close",
path_parts=__path_parts,
)
@_rewrite_parameters(
body_fields=("aliases", "mappings", "settings"),
)
async def create(
self,
*,
index: str,
aliases: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
mappings: t.Optional[t.Mapping[str, t.Any]] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
settings: t.Optional[t.Mapping[str, t.Any]] = None,
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
wait_for_active_shards: t.Optional[
t.Union[int, t.Union[str, t.Literal["all", "index-setting"]]]
] = None,
body: t.Optional[t.Dict[str, t.Any]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Create an index.
You can use the create index API to add a new index to an Elasticsearch cluster.
When creating an index, you can specify the following:</p>
<ul>
<li>Settings for the index.</li>
<li>Mappings for fields in the index.</li>
<li>Index aliases</li>
</ul>
<p><strong>Wait for active shards</strong></p>
<p>By default, index creation will only return a response to the client when the primary copies of each shard have been started, or the request times out.
The index creation response will indicate what happened.
For example, <code>acknowledged</code> indicates whether the index was successfully created in the cluster, <code>while shards_acknowledged</code> indicates whether the requisite number of shard copies were started for each shard in the index before timing out.
Note that it is still possible for either <code>acknowledged</code> or <code>shards_acknowledged</code> to be <code>false</code>, but for the index creation to be successful.
These values simply indicate whether the operation completed before the timeout.
If <code>acknowledged</code> is false, the request timed out before the cluster state was updated with the newly created index, but it probably will be created sometime soon.
If <code>shards_acknowledged</code> is false, then the request timed out before the requisite number of shards were started (by default just the primaries), even if the cluster state was successfully updated to reflect the newly created index (that is to say, <code>acknowledged</code> is <code>true</code>).</p>
<p>You can change the default of only waiting for the primary shards to start through the index setting <code>index.write.wait_for_active_shards</code>.
Note that changing this setting will also affect the <code>wait_for_active_shards</code> value on all subsequent write operations.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-create>`_
:param index: Name of the index you wish to create. Index names must meet the
following criteria: * Lowercase only * Cannot include `\\`, `/`, `*`, `?`,
`"`, `<`, `>`, `|`, ` ` (space character), `,`, or `#` * Indices prior to
7.0 could contain a colon (`:`), but that has been deprecated and will not
be supported in later versions * Cannot start with `-`, `_`, or `+` * Cannot
be `.` or `..` * Cannot be longer than 255 bytes (note thtat it is bytes,
so multi-byte characters will reach the limit faster) * Names starting with
`.` are deprecated, except for hidden indices and internal indices managed
by plugins
:param aliases: Aliases for the index.
:param mappings: Mapping for fields in the index. If specified, this mapping
can include: - Field names - Field data types - Mapping parameters
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
:param settings: Configuration options for the index.
:param timeout: Period to wait for a response. If no response is received before
the timeout expires, the request fails and returns an error.
:param wait_for_active_shards: The number of shard copies that must be active
before proceeding with the operation. Set to `all` or any positive integer
up to the total number of shards in the index (`number_of_replicas+1`).
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'index'")
__path_parts: t.Dict[str, str] = {"index": _quote(index)}
__path = f'/{__path_parts["index"]}'
__query: t.Dict[str, t.Any] = {}
__body: t.Dict[str, t.Any] = body if body is not None else {}
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
if timeout is not None:
__query["timeout"] = timeout
if wait_for_active_shards is not None:
__query["wait_for_active_shards"] = wait_for_active_shards
if not __body:
if aliases is not None:
__body["aliases"] = aliases
if mappings is not None:
__body["mappings"] = mappings
if settings is not None:
__body["settings"] = settings
if not __body:
__body = None # type: ignore[assignment]
__headers = {"accept": "application/json"}
if __body is not None:
__headers["content-type"] = "application/json"
return await self.perform_request( # type: ignore[return-value]
"PUT",
__path,
params=__query,
headers=__headers,
body=__body,
endpoint_id="indices.create",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def create_data_stream(
self,
*,
name: str,
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Create a data stream.</p>
<p>You must have a matching index template with data stream enabled.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-create-data-stream>`_
:param name: Name of the data stream, which must meet the following criteria:
Lowercase only; Cannot include `\\`, `/`, `*`, `?`, `"`, `<`, `>`, `|`, `,`,
`#`, `:`, or a space character; Cannot start with `-`, `_`, `+`, or `.ds-`;
Cannot be `.` or `..`; Cannot be longer than 255 bytes. Multi-byte characters
count towards this limit faster.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
:param timeout: Period to wait for a response. If no response is received before
the timeout expires, the request fails and returns an error.
"""
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'name'")
__path_parts: t.Dict[str, str] = {"name": _quote(name)}
__path = f'/_data_stream/{__path_parts["name"]}'
__query: t.Dict[str, t.Any] = {}
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
if timeout is not None:
__query["timeout"] = timeout
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"PUT",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.create_data_stream",
path_parts=__path_parts,
)
@_rewrite_parameters(
body_name="create_from",
)
@_stability_warning(Stability.EXPERIMENTAL)
async def create_from(
self,
*,
source: str,
dest: str,
create_from: t.Optional[t.Mapping[str, t.Any]] = None,
body: t.Optional[t.Mapping[str, t.Any]] = None,
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
pretty: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Create an index from a source index.</p>
<p>Copy the mappings and settings from the source index to a destination index while allowing request settings and mappings to override the source values.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-create-from>`_
:param source: The source index or data stream name
:param dest: The destination index or data stream name
:param create_from:
"""
if source in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'source'")
if dest in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'dest'")
if create_from is None and body is None:
raise ValueError(
"Empty value passed for parameters 'create_from' and 'body', one of them should be set."
)
elif create_from is not None and body is not None:
raise ValueError("Cannot set both 'create_from' and 'body'")
__path_parts: t.Dict[str, str] = {
"source": _quote(source),
"dest": _quote(dest),
}
__path = f'/_create_from/{__path_parts["source"]}/{__path_parts["dest"]}'
__query: t.Dict[str, t.Any] = {}
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if pretty is not None:
__query["pretty"] = pretty
__body = create_from if create_from is not None else body
__headers = {"accept": "application/json", "content-type": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"PUT",
__path,
params=__query,
headers=__headers,
body=__body,
endpoint_id="indices.create_from",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def data_streams_stats(
self,
*,
name: t.Optional[str] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
pretty: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Get data stream stats.</p>
<p>Get statistics for one or more data streams.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-data-streams-stats-1>`_
:param name: Comma-separated list of data streams used to limit the request.
Wildcard expressions (`*`) are supported. To target all data streams in a
cluster, omit this parameter or use `*`.
:param expand_wildcards: Type of data stream that wildcard patterns can match.
Supports comma-separated values, such as `open,hidden`.
"""
__path_parts: t.Dict[str, str]
if name not in SKIP_IN_PATH:
__path_parts = {"name": _quote(name)}
__path = f'/_data_stream/{__path_parts["name"]}/_stats'
else:
__path_parts = {}
__path = "/_data_stream/_stats"
__query: t.Dict[str, t.Any] = {}
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if pretty is not None:
__query["pretty"] = pretty
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"GET",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.data_streams_stats",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def delete(
self,
*,
index: t.Union[str, t.Sequence[str]],
allow_no_indices: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
ignore_unavailable: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Delete indices.
Deleting an index deletes its documents, shards, and metadata.
It does not delete related Kibana components, such as data views, visualizations, or dashboards.</p>
<p>You cannot delete the current write index of a data stream.
To delete the index, you must roll over the data stream so a new write index is created.
You can then use the delete index API to delete the previous write index.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-delete>`_
:param index: Comma-separated list of indices to delete. You cannot specify index
aliases. By default, this parameter does not support wildcards (`*`) or `_all`.
To use wildcards or `_all`, set the `action.destructive_requires_name` cluster
setting to `false`.
:param allow_no_indices: If `false`, the request returns an error if any wildcard
expression, index alias, or `_all` value targets only missing or closed indices.
This behavior applies even if the request targets other open indices.
:param expand_wildcards: Type of index that wildcard patterns can match. If the
request can target data streams, this argument determines whether wildcard
expressions match hidden data streams. Supports comma-separated values, such
as `open,hidden`.
:param ignore_unavailable: If `false`, the request returns an error if it targets
a missing or closed index.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
:param timeout: Period to wait for a response. If no response is received before
the timeout expires, the request fails and returns an error.
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'index'")
__path_parts: t.Dict[str, str] = {"index": _quote(index)}
__path = f'/{__path_parts["index"]}'
__query: t.Dict[str, t.Any] = {}
if allow_no_indices is not None:
__query["allow_no_indices"] = allow_no_indices
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if ignore_unavailable is not None:
__query["ignore_unavailable"] = ignore_unavailable
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
if timeout is not None:
__query["timeout"] = timeout
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"DELETE",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.delete",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def delete_alias(
self,
*,
index: t.Union[str, t.Sequence[str]],
name: t.Union[str, t.Sequence[str]],
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Delete an alias.
Removes a data stream or index from an alias.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-delete-alias>`_
:param index: Comma-separated list of data streams or indices used to limit the
request. Supports wildcards (`*`).
:param name: Comma-separated list of aliases to remove. Supports wildcards (`*`).
To remove all aliases, use `*` or `_all`.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
:param timeout: Period to wait for a response. If no response is received before
the timeout expires, the request fails and returns an error.
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'index'")
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'name'")
__path_parts: t.Dict[str, str] = {"index": _quote(index), "name": _quote(name)}
__path = f'/{__path_parts["index"]}/_alias/{__path_parts["name"]}'
__query: t.Dict[str, t.Any] = {}
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
if timeout is not None:
__query["timeout"] = timeout
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"DELETE",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.delete_alias",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def delete_data_lifecycle(
self,
*,
name: t.Union[str, t.Sequence[str]],
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Delete data stream lifecycles.
Removes the data stream lifecycle from a data stream, rendering it not managed by the data stream lifecycle.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-delete-data-lifecycle>`_
:param name: A comma-separated list of data streams of which the data stream
lifecycle will be deleted; use `*` to get all data streams
:param expand_wildcards: Whether wildcard expressions should get expanded to
open or closed indices (default: open)
:param master_timeout: Specify timeout for connection to master
:param timeout: Explicit timestamp for the document
"""
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'name'")
__path_parts: t.Dict[str, str] = {"name": _quote(name)}
__path = f'/_data_stream/{__path_parts["name"]}/_lifecycle'
__query: t.Dict[str, t.Any] = {}
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
if timeout is not None:
__query["timeout"] = timeout
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"DELETE",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.delete_data_lifecycle",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def delete_data_stream(
self,
*,
name: t.Union[str, t.Sequence[str]],
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Delete data streams.
Deletes one or more data streams and their backing indices.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-delete-data-stream>`_
:param name: Comma-separated list of data streams to delete. Wildcard (`*`) expressions
are supported.
:param expand_wildcards: Type of data stream that wildcard patterns can match.
Supports comma-separated values,such as `open,hidden`.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
"""
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'name'")
__path_parts: t.Dict[str, str] = {"name": _quote(name)}
__path = f'/_data_stream/{__path_parts["name"]}'
__query: t.Dict[str, t.Any] = {}
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"DELETE",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.delete_data_stream",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def delete_data_stream_options(
self,
*,
name: t.Union[str, t.Sequence[str]],
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Delete data stream options.
Removes the data stream options from a data stream.</p>
`<https://www.elastic.co/guide/en/elasticsearch/reference/9.1/index.html>`_
:param name: A comma-separated list of data streams of which the data stream
options will be deleted; use `*` to get all data streams
:param expand_wildcards: Whether wildcard expressions should get expanded to
open or closed indices (default: open)
:param master_timeout: Specify timeout for connection to master
:param timeout: Explicit timestamp for the document
"""
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'name'")
__path_parts: t.Dict[str, str] = {"name": _quote(name)}
__path = f'/_data_stream/{__path_parts["name"]}/_options'
__query: t.Dict[str, t.Any] = {}
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
if timeout is not None:
__query["timeout"] = timeout
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"DELETE",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.delete_data_stream_options",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def delete_index_template(
self,
*,
name: t.Union[str, t.Sequence[str]],
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Delete an index template.
The provided <!-- raw HTML omitted --> may contain multiple template names separated by a comma. If multiple template
names are specified then there is no wildcard support and the provided names should match completely with
existing templates.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-delete-index-template>`_
:param name: Comma-separated list of index template names used to limit the request.
Wildcard (*) expressions are supported.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
:param timeout: Period to wait for a response. If no response is received before
the timeout expires, the request fails and returns an error.
"""
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'name'")
__path_parts: t.Dict[str, str] = {"name": _quote(name)}
__path = f'/_index_template/{__path_parts["name"]}'
__query: t.Dict[str, t.Any] = {}
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
if timeout is not None:
__query["timeout"] = timeout
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"DELETE",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.delete_index_template",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def delete_template(
self,
*,
name: str,
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Delete a legacy index template.
IMPORTANT: This documentation is about legacy index templates, which are deprecated and will be replaced by the composable templates introduced in Elasticsearch 7.8.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-delete-template>`_
:param name: The name of the legacy index template to delete. Wildcard (`*`)
expressions are supported.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
:param timeout: Period to wait for a response. If no response is received before
the timeout expires, the request fails and returns an error.
"""
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'name'")
__path_parts: t.Dict[str, str] = {"name": _quote(name)}
__path = f'/_template/{__path_parts["name"]}'
__query: t.Dict[str, t.Any] = {}
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
if timeout is not None:
__query["timeout"] = timeout
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"DELETE",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.delete_template",
path_parts=__path_parts,
)
@_rewrite_parameters()
@_stability_warning(Stability.EXPERIMENTAL)
async def disk_usage(
self,
*,
index: t.Union[str, t.Sequence[str]],
allow_no_indices: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
flush: t.Optional[bool] = None,
human: t.Optional[bool] = None,
ignore_unavailable: t.Optional[bool] = None,
pretty: t.Optional[bool] = None,
run_expensive_tasks: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Analyze the index disk usage.
Analyze the disk usage of each field of an index or data stream.
This API might not support indices created in previous Elasticsearch versions.
The result of a small index can be inaccurate as some parts of an index might not be analyzed by the API.</p>
<p>NOTE: The total size of fields of the analyzed shards of the index in the response is usually smaller than the index <code>store_size</code> value because some small metadata files are ignored and some parts of data files might not be scanned by the API.
Since stored fields are stored together in a compressed format, the sizes of stored fields are also estimates and can be inaccurate.
The stored size of the <code>_id</code> field is likely underestimated while the <code>_source</code> field is overestimated.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-disk-usage>`_
:param index: Comma-separated list of data streams, indices, and aliases used
to limit the request. It’s recommended to execute this API with a single
index (or the latest backing index of a data stream) as the API consumes
resources significantly.
:param allow_no_indices: If false, the request returns an error if any wildcard
expression, index alias, or `_all` value targets only missing or closed indices.
This behavior applies even if the request targets other open indices. For
example, a request targeting `foo*,bar*` returns an error if an index starts
with `foo` but no index starts with `bar`.
:param expand_wildcards: Type of index that wildcard patterns can match. If the
request can target data streams, this argument determines whether wildcard
expressions match hidden data streams. Supports comma-separated values, such
as `open,hidden`.
:param flush: If `true`, the API performs a flush before analysis. If `false`,
the response may not include uncommitted data.
:param ignore_unavailable: If `true`, missing or closed indices are not included
in the response.
:param run_expensive_tasks: Analyzing field disk usage is resource-intensive.
To use the API, this parameter must be set to `true`.
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'index'")
__path_parts: t.Dict[str, str] = {"index": _quote(index)}
__path = f'/{__path_parts["index"]}/_disk_usage'
__query: t.Dict[str, t.Any] = {}
if allow_no_indices is not None:
__query["allow_no_indices"] = allow_no_indices
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if flush is not None:
__query["flush"] = flush
if human is not None:
__query["human"] = human
if ignore_unavailable is not None:
__query["ignore_unavailable"] = ignore_unavailable
if pretty is not None:
__query["pretty"] = pretty
if run_expensive_tasks is not None:
__query["run_expensive_tasks"] = run_expensive_tasks
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"POST",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.disk_usage",
path_parts=__path_parts,
)
@_rewrite_parameters(
body_name="config",
)
@_stability_warning(Stability.EXPERIMENTAL)
async def downsample(
self,
*,
index: str,
target_index: str,
config: t.Optional[t.Mapping[str, t.Any]] = None,
body: t.Optional[t.Mapping[str, t.Any]] = None,
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
pretty: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Downsample an index.
Aggregate a time series (TSDS) index and store pre-computed statistical summaries (<code>min</code>, <code>max</code>, <code>sum</code>, <code>value_count</code> and <code>avg</code>) for each metric field grouped by a configured time interval.
For example, a TSDS index that contains metrics sampled every 10 seconds can be downsampled to an hourly index.
All documents within an hour interval are summarized and stored as a single document in the downsample index.</p>
<p>NOTE: Only indices in a time series data stream are supported.
Neither field nor document level security can be defined on the source index.
The source index must be read only (<code>index.blocks.write: true</code>).</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-downsample>`_
:param index: Name of the time series index to downsample.
:param target_index: Name of the index to create.
:param config:
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'index'")
if target_index in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'target_index'")
if config is None and body is None:
raise ValueError(
"Empty value passed for parameters 'config' and 'body', one of them should be set."
)
elif config is not None and body is not None:
raise ValueError("Cannot set both 'config' and 'body'")
__path_parts: t.Dict[str, str] = {
"index": _quote(index),
"target_index": _quote(target_index),
}
__path = f'/{__path_parts["index"]}/_downsample/{__path_parts["target_index"]}'
__query: t.Dict[str, t.Any] = {}
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if pretty is not None:
__query["pretty"] = pretty
__body = config if config is not None else body
__headers = {"accept": "application/json", "content-type": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"POST",
__path,
params=__query,
headers=__headers,
body=__body,
endpoint_id="indices.downsample",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def exists(
self,
*,
index: t.Union[str, t.Sequence[str]],
allow_no_indices: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
flat_settings: t.Optional[bool] = None,
human: t.Optional[bool] = None,
ignore_unavailable: t.Optional[bool] = None,
include_defaults: t.Optional[bool] = None,
local: t.Optional[bool] = None,
pretty: t.Optional[bool] = None,
) -> HeadApiResponse:
"""
.. raw:: html
<p>Check indices.
Check if one or more indices, index aliases, or data streams exist.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-exists>`_
:param index: Comma-separated list of data streams, indices, and aliases. Supports
wildcards (`*`).
:param allow_no_indices: If `false`, the request returns an error if any wildcard
expression, index alias, or `_all` value targets only missing or closed indices.
This behavior applies even if the request targets other open indices.
:param expand_wildcards: Type of index that wildcard patterns can match. If the
request can target data streams, this argument determines whether wildcard
expressions match hidden data streams. Supports comma-separated values, such
as `open,hidden`.
:param flat_settings: If `true`, returns settings in flat format.
:param ignore_unavailable: If `false`, the request returns an error if it targets
a missing or closed index.
:param include_defaults: If `true`, return all default settings in the response.
:param local: If `true`, the request retrieves information from the local node
only.
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'index'")
__path_parts: t.Dict[str, str] = {"index": _quote(index)}
__path = f'/{__path_parts["index"]}'
__query: t.Dict[str, t.Any] = {}
if allow_no_indices is not None:
__query["allow_no_indices"] = allow_no_indices
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if flat_settings is not None:
__query["flat_settings"] = flat_settings
if human is not None:
__query["human"] = human
if ignore_unavailable is not None:
__query["ignore_unavailable"] = ignore_unavailable
if include_defaults is not None:
__query["include_defaults"] = include_defaults
if local is not None:
__query["local"] = local
if pretty is not None:
__query["pretty"] = pretty
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"HEAD",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.exists",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def exists_alias(
self,
*,
name: t.Union[str, t.Sequence[str]],
index: t.Optional[t.Union[str, t.Sequence[str]]] = None,
allow_no_indices: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
ignore_unavailable: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
) -> HeadApiResponse:
"""
.. raw:: html
<p>Check aliases.</p>
<p>Check if one or more data stream or index aliases exist.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-exists-alias>`_
:param name: Comma-separated list of aliases to check. Supports wildcards (`*`).
:param index: Comma-separated list of data streams or indices used to limit the
request. Supports wildcards (`*`). To target all data streams and indices,
omit this parameter or use `*` or `_all`.
:param allow_no_indices: If `false`, the request returns an error if any wildcard
expression, index alias, or `_all` value targets only missing or closed indices.
This behavior applies even if the request targets other open indices.
:param expand_wildcards: Type of index that wildcard patterns can match. If the
request can target data streams, this argument determines whether wildcard
expressions match hidden data streams. Supports comma-separated values, such
as `open,hidden`.
:param ignore_unavailable: If `false`, requests that include a missing data stream
or index in the target indices or data streams return an error.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
"""
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'name'")
__path_parts: t.Dict[str, str]
if index not in SKIP_IN_PATH and name not in SKIP_IN_PATH:
__path_parts = {"index": _quote(index), "name": _quote(name)}
__path = f'/{__path_parts["index"]}/_alias/{__path_parts["name"]}'
elif name not in SKIP_IN_PATH:
__path_parts = {"name": _quote(name)}
__path = f'/_alias/{__path_parts["name"]}'
else:
raise ValueError("Couldn't find a path for the given parameters")
__query: t.Dict[str, t.Any] = {}
if allow_no_indices is not None:
__query["allow_no_indices"] = allow_no_indices
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if ignore_unavailable is not None:
__query["ignore_unavailable"] = ignore_unavailable
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"HEAD",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.exists_alias",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def exists_index_template(
self,
*,
name: str,
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
flat_settings: t.Optional[bool] = None,
human: t.Optional[bool] = None,
local: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
) -> HeadApiResponse:
"""
.. raw:: html
<p>Check index templates.</p>
<p>Check whether index templates exist.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-exists-index-template>`_
:param name: Comma-separated list of index template names used to limit the request.
Wildcard (*) expressions are supported.
:param flat_settings: If true, returns settings in flat format.
:param local: If true, the request retrieves information from the local node
only. Defaults to false, which means information is retrieved from the master
node.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
"""
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'name'")
__path_parts: t.Dict[str, str] = {"name": _quote(name)}
__path = f'/_index_template/{__path_parts["name"]}'
__query: t.Dict[str, t.Any] = {}
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if flat_settings is not None:
__query["flat_settings"] = flat_settings
if human is not None:
__query["human"] = human
if local is not None:
__query["local"] = local
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"HEAD",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.exists_index_template",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def exists_template(
self,
*,
name: t.Union[str, t.Sequence[str]],
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
flat_settings: t.Optional[bool] = None,
human: t.Optional[bool] = None,
local: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
) -> HeadApiResponse:
"""
.. raw:: html
<p>Check existence of index templates.
Get information about whether index templates exist.
Index templates define settings, mappings, and aliases that can be applied automatically to new indices.</p>
<p>IMPORTANT: This documentation is about legacy index templates, which are deprecated and will be replaced by the composable templates introduced in Elasticsearch 7.8.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-exists-template>`_
:param name: A comma-separated list of index template names used to limit the
request. Wildcard (`*`) expressions are supported.
:param flat_settings: Indicates whether to use a flat format for the response.
:param local: Indicates whether to get information from the local node only.
:param master_timeout: The period to wait for the master node. If the master
node is not available before the timeout expires, the request fails and returns
an error. To indicate that the request should never timeout, set it to `-1`.
"""
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'name'")
__path_parts: t.Dict[str, str] = {"name": _quote(name)}
__path = f'/_template/{__path_parts["name"]}'
__query: t.Dict[str, t.Any] = {}
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if flat_settings is not None:
__query["flat_settings"] = flat_settings
if human is not None:
__query["human"] = human
if local is not None:
__query["local"] = local
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"HEAD",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.exists_template",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def explain_data_lifecycle(
self,
*,
index: t.Union[str, t.Sequence[str]],
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
include_defaults: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Get the status for a data stream lifecycle.
Get information about an index or data stream's current data stream lifecycle status, such as time since index creation, time since rollover, the lifecycle configuration managing the index, or any errors encountered during lifecycle execution.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-explain-data-lifecycle>`_
:param index: The name of the index to explain
:param include_defaults: indicates if the API should return the default values
the system uses for the index's lifecycle
:param master_timeout: Specify timeout for connection to master
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'index'")
__path_parts: t.Dict[str, str] = {"index": _quote(index)}
__path = f'/{__path_parts["index"]}/_lifecycle/explain'
__query: t.Dict[str, t.Any] = {}
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if include_defaults is not None:
__query["include_defaults"] = include_defaults
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"GET",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.explain_data_lifecycle",
path_parts=__path_parts,
)
@_rewrite_parameters()
@_stability_warning(Stability.EXPERIMENTAL)
async def field_usage_stats(
self,
*,
index: t.Union[str, t.Sequence[str]],
allow_no_indices: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
fields: t.Optional[t.Union[str, t.Sequence[str]]] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
ignore_unavailable: t.Optional[bool] = None,
pretty: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Get field usage stats.
Get field usage information for each shard and field of an index.
Field usage statistics are automatically captured when queries are running on a cluster.
A shard-level search request that accesses a given field, even if multiple times during that request, is counted as a single use.</p>
<p>The response body reports the per-shard usage count of the data structures that back the fields in the index.
A given request will increment each count by a maximum value of 1, even if the request accesses the same field multiple times.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-field-usage-stats>`_
:param index: Comma-separated list or wildcard expression of index names used
to limit the request.
:param allow_no_indices: If `false`, the request returns an error if any wildcard
expression, index alias, or `_all` value targets only missing or closed indices.
This behavior applies even if the request targets other open indices. For
example, a request targeting `foo*,bar*` returns an error if an index starts
with `foo` but no index starts with `bar`.
:param expand_wildcards: Type of index that wildcard patterns can match. If the
request can target data streams, this argument determines whether wildcard
expressions match hidden data streams. Supports comma-separated values, such
as `open,hidden`.
:param fields: Comma-separated list or wildcard expressions of fields to include
in the statistics.
:param ignore_unavailable: If `true`, missing or closed indices are not included
in the response.
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'index'")
__path_parts: t.Dict[str, str] = {"index": _quote(index)}
__path = f'/{__path_parts["index"]}/_field_usage_stats'
__query: t.Dict[str, t.Any] = {}
if allow_no_indices is not None:
__query["allow_no_indices"] = allow_no_indices
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if fields is not None:
__query["fields"] = fields
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if ignore_unavailable is not None:
__query["ignore_unavailable"] = ignore_unavailable
if pretty is not None:
__query["pretty"] = pretty
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"GET",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.field_usage_stats",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def flush(
self,
*,
index: t.Optional[t.Union[str, t.Sequence[str]]] = None,
allow_no_indices: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
force: t.Optional[bool] = None,
human: t.Optional[bool] = None,
ignore_unavailable: t.Optional[bool] = None,
pretty: t.Optional[bool] = None,
wait_if_ongoing: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Flush data streams or indices.
Flushing a data stream or index is the process of making sure that any data that is currently only stored in the transaction log is also permanently stored in the Lucene index.
When restarting, Elasticsearch replays any unflushed operations from the transaction log into the Lucene index to bring it back into the state that it was in before the restart.
Elasticsearch automatically triggers flushes as needed, using heuristics that trade off the size of the unflushed transaction log against the cost of performing each flush.</p>
<p>After each operation has been flushed it is permanently stored in the Lucene index.
This may mean that there is no need to maintain an additional copy of it in the transaction log.
The transaction log is made up of multiple files, called generations, and Elasticsearch will delete any generation files when they are no longer needed, freeing up disk space.</p>
<p>It is also possible to trigger a flush on one or more indices using the flush API, although it is rare for users to need to call this API directly.
If you call the flush API after indexing some documents then a successful response indicates that Elasticsearch has flushed all the documents that were indexed before the flush API was called.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-flush>`_
:param index: Comma-separated list of data streams, indices, and aliases to flush.
Supports wildcards (`*`). To flush all data streams and indices, omit this
parameter or use `*` or `_all`.
:param allow_no_indices: If `false`, the request returns an error if any wildcard
expression, index alias, or `_all` value targets only missing or closed indices.
This behavior applies even if the request targets other open indices.
:param expand_wildcards: Type of index that wildcard patterns can match. If the
request can target data streams, this argument determines whether wildcard
expressions match hidden data streams. Supports comma-separated values, such
as `open,hidden`.
:param force: If `true`, the request forces a flush even if there are no changes
to commit to the index.
:param ignore_unavailable: If `false`, the request returns an error if it targets
a missing or closed index.
:param wait_if_ongoing: If `true`, the flush operation blocks until execution
when another flush operation is running. If `false`, Elasticsearch returns
an error if you request a flush when another flush operation is running.
"""
__path_parts: t.Dict[str, str]
if index not in SKIP_IN_PATH:
__path_parts = {"index": _quote(index)}
__path = f'/{__path_parts["index"]}/_flush'
else:
__path_parts = {}
__path = "/_flush"
__query: t.Dict[str, t.Any] = {}
if allow_no_indices is not None:
__query["allow_no_indices"] = allow_no_indices
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if force is not None:
__query["force"] = force
if human is not None:
__query["human"] = human
if ignore_unavailable is not None:
__query["ignore_unavailable"] = ignore_unavailable
if pretty is not None:
__query["pretty"] = pretty
if wait_if_ongoing is not None:
__query["wait_if_ongoing"] = wait_if_ongoing
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"POST",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.flush",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def forcemerge(
self,
*,
index: t.Optional[t.Union[str, t.Sequence[str]]] = None,
allow_no_indices: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
flush: t.Optional[bool] = None,
human: t.Optional[bool] = None,
ignore_unavailable: t.Optional[bool] = None,
max_num_segments: t.Optional[int] = None,
only_expunge_deletes: t.Optional[bool] = None,
pretty: t.Optional[bool] = None,
wait_for_completion: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Force a merge.
Perform the force merge operation on the shards of one or more indices.
For data streams, the API forces a merge on the shards of the stream's backing indices.</p>
<p>Merging reduces the number of segments in each shard by merging some of them together and also frees up the space used by deleted documents.
Merging normally happens automatically, but sometimes it is useful to trigger a merge manually.</p>
<p>WARNING: We recommend force merging only a read-only index (meaning the index is no longer receiving writes).
When documents are updated or deleted, the old version is not immediately removed but instead soft-deleted and marked with a "tombstone".
These soft-deleted documents are automatically cleaned up during regular segment merges.
But force merge can cause very large (greater than 5 GB) segments to be produced, which are not eligible for regular merges.
So the number of soft-deleted documents can then grow rapidly, resulting in higher disk usage and worse search performance.
If you regularly force merge an index receiving writes, this can also make snapshots more expensive, since the new documents can't be backed up incrementally.</p>
<p><strong>Blocks during a force merge</strong></p>
<p>Calls to this API block until the merge is complete (unless request contains <code>wait_for_completion=false</code>).
If the client connection is lost before completion then the force merge process will continue in the background.
Any new requests to force merge the same indices will also block until the ongoing force merge is complete.</p>
<p><strong>Running force merge asynchronously</strong></p>
<p>If the request contains <code>wait_for_completion=false</code>, Elasticsearch performs some preflight checks, launches the request, and returns a task you can use to get the status of the task.
However, you can not cancel this task as the force merge task is not cancelable.
Elasticsearch creates a record of this task as a document at <code>_tasks/<task_id></code>.
When you are done with a task, you should delete the task document so Elasticsearch can reclaim the space.</p>
<p><strong>Force merging multiple indices</strong></p>
<p>You can force merge multiple indices with a single request by targeting:</p>
<ul>
<li>One or more data streams that contain multiple backing indices</li>
<li>Multiple indices</li>
<li>One or more aliases</li>
<li>All data streams and indices in a cluster</li>
</ul>
<p>Each targeted shard is force-merged separately using the force_merge threadpool.
By default each node only has a single <code>force_merge</code> thread which means that the shards on that node are force-merged one at a time.
If you expand the <code>force_merge</code> threadpool on a node then it will force merge its shards in parallel</p>
<p>Force merge makes the storage for the shard being merged temporarily increase, as it may require free space up to triple its size in case <code>max_num_segments parameter</code> is set to <code>1</code>, to rewrite all segments into a new one.</p>
<p><strong>Data streams and time-based indices</strong></p>
<p>Force-merging is useful for managing a data stream's older backing indices and other time-based indices, particularly after a rollover.
In these cases, each index only receives indexing traffic for a certain period of time.
Once an index receive no more writes, its shards can be force-merged to a single segment.
This can be a good idea because single-segment shards can sometimes use simpler and more efficient data structures to perform searches.
For example:</p>
<pre><code>POST /.ds-my-data-stream-2099.03.07-000001/_forcemerge?max_num_segments=1
</code></pre>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-forcemerge>`_
:param index: A comma-separated list of index names; use `_all` or empty string
to perform the operation on all indices
:param allow_no_indices: Whether to ignore if a wildcard indices expression resolves
into no concrete indices. (This includes `_all` string or when no indices
have been specified)
:param expand_wildcards: Whether to expand wildcard expression to concrete indices
that are open, closed or both.
:param flush: Specify whether the index should be flushed after performing the
operation (default: true)
:param ignore_unavailable: Whether specified concrete indices should be ignored
when unavailable (missing or closed)
:param max_num_segments: The number of segments the index should be merged into
(default: dynamic)
:param only_expunge_deletes: Specify whether the operation should only expunge
deleted documents
:param wait_for_completion: Should the request wait until the force merge is
completed.
"""
__path_parts: t.Dict[str, str]
if index not in SKIP_IN_PATH:
__path_parts = {"index": _quote(index)}
__path = f'/{__path_parts["index"]}/_forcemerge'
else:
__path_parts = {}
__path = "/_forcemerge"
__query: t.Dict[str, t.Any] = {}
if allow_no_indices is not None:
__query["allow_no_indices"] = allow_no_indices
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if flush is not None:
__query["flush"] = flush
if human is not None:
__query["human"] = human
if ignore_unavailable is not None:
__query["ignore_unavailable"] = ignore_unavailable
if max_num_segments is not None:
__query["max_num_segments"] = max_num_segments
if only_expunge_deletes is not None:
__query["only_expunge_deletes"] = only_expunge_deletes
if pretty is not None:
__query["pretty"] = pretty
if wait_for_completion is not None:
__query["wait_for_completion"] = wait_for_completion
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"POST",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.forcemerge",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def get(
self,
*,
index: t.Union[str, t.Sequence[str]],
allow_no_indices: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
features: t.Optional[
t.Union[
t.Sequence[t.Union[str, t.Literal["aliases", "mappings", "settings"]]],
t.Union[str, t.Literal["aliases", "mappings", "settings"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
flat_settings: t.Optional[bool] = None,
human: t.Optional[bool] = None,
ignore_unavailable: t.Optional[bool] = None,
include_defaults: t.Optional[bool] = None,
local: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Get index information.
Get information about one or more indices. For data streams, the API returns information about the
stream’s backing indices.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get>`_
:param index: Comma-separated list of data streams, indices, and index aliases
used to limit the request. Wildcard expressions (*) are supported.
:param allow_no_indices: If false, the request returns an error if any wildcard
expression, index alias, or _all value targets only missing or closed indices.
This behavior applies even if the request targets other open indices. For
example, a request targeting foo*,bar* returns an error if an index starts
with foo but no index starts with bar.
:param expand_wildcards: Type of index that wildcard expressions can match. If
the request can target data streams, this argument determines whether wildcard
expressions match hidden data streams. Supports comma-separated values, such
as open,hidden.
:param features: Return only information on specified index features
:param flat_settings: If true, returns settings in flat format.
:param ignore_unavailable: If false, requests that target a missing index return
an error.
:param include_defaults: If true, return all default settings in the response.
:param local: If true, the request retrieves information from the local node
only. Defaults to false, which means information is retrieved from the master
node.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'index'")
__path_parts: t.Dict[str, str] = {"index": _quote(index)}
__path = f'/{__path_parts["index"]}'
__query: t.Dict[str, t.Any] = {}
if allow_no_indices is not None:
__query["allow_no_indices"] = allow_no_indices
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if features is not None:
__query["features"] = features
if filter_path is not None:
__query["filter_path"] = filter_path
if flat_settings is not None:
__query["flat_settings"] = flat_settings
if human is not None:
__query["human"] = human
if ignore_unavailable is not None:
__query["ignore_unavailable"] = ignore_unavailable
if include_defaults is not None:
__query["include_defaults"] = include_defaults
if local is not None:
__query["local"] = local
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"GET",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.get",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def get_alias(
self,
*,
index: t.Optional[t.Union[str, t.Sequence[str]]] = None,
name: t.Optional[t.Union[str, t.Sequence[str]]] = None,
allow_no_indices: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
ignore_unavailable: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Get aliases.
Retrieves information for one or more data stream or index aliases.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get-alias>`_
:param index: Comma-separated list of data streams or indices used to limit the
request. Supports wildcards (`*`). To target all data streams and indices,
omit this parameter or use `*` or `_all`.
:param name: Comma-separated list of aliases to retrieve. Supports wildcards
(`*`). To retrieve all aliases, omit this parameter or use `*` or `_all`.
:param allow_no_indices: If `false`, the request returns an error if any wildcard
expression, index alias, or `_all` value targets only missing or closed indices.
This behavior applies even if the request targets other open indices.
:param expand_wildcards: Type of index that wildcard patterns can match. If the
request can target data streams, this argument determines whether wildcard
expressions match hidden data streams. Supports comma-separated values, such
as `open,hidden`.
:param ignore_unavailable: If `false`, the request returns an error if it targets
a missing or closed index.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
"""
__path_parts: t.Dict[str, str]
if index not in SKIP_IN_PATH and name not in SKIP_IN_PATH:
__path_parts = {"index": _quote(index), "name": _quote(name)}
__path = f'/{__path_parts["index"]}/_alias/{__path_parts["name"]}'
elif index not in SKIP_IN_PATH:
__path_parts = {"index": _quote(index)}
__path = f'/{__path_parts["index"]}/_alias'
elif name not in SKIP_IN_PATH:
__path_parts = {"name": _quote(name)}
__path = f'/_alias/{__path_parts["name"]}'
else:
__path_parts = {}
__path = "/_alias"
__query: t.Dict[str, t.Any] = {}
if allow_no_indices is not None:
__query["allow_no_indices"] = allow_no_indices
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if ignore_unavailable is not None:
__query["ignore_unavailable"] = ignore_unavailable
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"GET",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.get_alias",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def get_data_lifecycle(
self,
*,
name: t.Union[str, t.Sequence[str]],
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
include_defaults: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Get data stream lifecycles.</p>
<p>Get the data stream lifecycle configuration of one or more data streams.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get-data-lifecycle>`_
:param name: Comma-separated list of data streams to limit the request. Supports
wildcards (`*`). To target all data streams, omit this parameter or use `*`
or `_all`.
:param expand_wildcards: Type of data stream that wildcard patterns can match.
Supports comma-separated values, such as `open,hidden`.
:param include_defaults: If `true`, return all default settings in the response.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
"""
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'name'")
__path_parts: t.Dict[str, str] = {"name": _quote(name)}
__path = f'/_data_stream/{__path_parts["name"]}/_lifecycle'
__query: t.Dict[str, t.Any] = {}
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if include_defaults is not None:
__query["include_defaults"] = include_defaults
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"GET",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.get_data_lifecycle",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def get_data_lifecycle_stats(
self,
*,
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
pretty: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Get data stream lifecycle stats.
Get statistics about the data streams that are managed by a data stream lifecycle.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get-data-lifecycle-stats>`_
"""
__path_parts: t.Dict[str, str] = {}
__path = "/_lifecycle/stats"
__query: t.Dict[str, t.Any] = {}
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if pretty is not None:
__query["pretty"] = pretty
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"GET",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.get_data_lifecycle_stats",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def get_data_stream(
self,
*,
name: t.Optional[t.Union[str, t.Sequence[str]]] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
include_defaults: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
verbose: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Get data streams.</p>
<p>Get information about one or more data streams.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get-data-stream>`_
:param name: Comma-separated list of data stream names used to limit the request.
Wildcard (`*`) expressions are supported. If omitted, all data streams are
returned.
:param expand_wildcards: Type of data stream that wildcard patterns can match.
Supports comma-separated values, such as `open,hidden`.
:param include_defaults: If true, returns all relevant default configurations
for the index template.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
:param verbose: Whether the maximum timestamp for each data stream should be
calculated and returned.
"""
__path_parts: t.Dict[str, str]
if name not in SKIP_IN_PATH:
__path_parts = {"name": _quote(name)}
__path = f'/_data_stream/{__path_parts["name"]}'
else:
__path_parts = {}
__path = "/_data_stream"
__query: t.Dict[str, t.Any] = {}
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if include_defaults is not None:
__query["include_defaults"] = include_defaults
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
if verbose is not None:
__query["verbose"] = verbose
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"GET",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.get_data_stream",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def get_data_stream_options(
self,
*,
name: t.Union[str, t.Sequence[str]],
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Get data stream options.</p>
<p>Get the data stream options configuration of one or more data streams.</p>
`<https://www.elastic.co/guide/en/elasticsearch/reference/9.1/index.html>`_
:param name: Comma-separated list of data streams to limit the request. Supports
wildcards (`*`). To target all data streams, omit this parameter or use `*`
or `_all`.
:param expand_wildcards: Type of data stream that wildcard patterns can match.
Supports comma-separated values, such as `open,hidden`.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
"""
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'name'")
__path_parts: t.Dict[str, str] = {"name": _quote(name)}
__path = f'/_data_stream/{__path_parts["name"]}/_options'
__query: t.Dict[str, t.Any] = {}
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"GET",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.get_data_stream_options",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def get_data_stream_settings(
self,
*,
name: t.Union[str, t.Sequence[str]],
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Get data stream settings.</p>
<p>Get setting information for one or more data streams.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get-data-stream-settings>`_
:param name: A comma-separated list of data streams or data stream patterns.
Supports wildcards (`*`).
:param master_timeout: The period to wait for a connection to the master node.
If no response is received before the timeout expires, the request fails
and returns an error.
"""
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'name'")
__path_parts: t.Dict[str, str] = {"name": _quote(name)}
__path = f'/_data_stream/{__path_parts["name"]}/_settings'
__query: t.Dict[str, t.Any] = {}
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"GET",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.get_data_stream_settings",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def get_field_mapping(
self,
*,
fields: t.Union[str, t.Sequence[str]],
index: t.Optional[t.Union[str, t.Sequence[str]]] = None,
allow_no_indices: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
ignore_unavailable: t.Optional[bool] = None,
include_defaults: t.Optional[bool] = None,
pretty: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Get mapping definitions.
Retrieves mapping definitions for one or more fields.
For data streams, the API retrieves field mappings for the stream’s backing indices.</p>
<p>This API is useful if you don't need a complete mapping or if an index mapping contains a large number of fields.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get-mapping>`_
:param fields: Comma-separated list or wildcard expression of fields used to
limit returned information. Supports wildcards (`*`).
:param index: Comma-separated list of data streams, indices, and aliases used
to limit the request. Supports wildcards (`*`). To target all data streams
and indices, omit this parameter or use `*` or `_all`.
:param allow_no_indices: If `false`, the request returns an error if any wildcard
expression, index alias, or `_all` value targets only missing or closed indices.
This behavior applies even if the request targets other open indices.
:param expand_wildcards: Type of index that wildcard patterns can match. If the
request can target data streams, this argument determines whether wildcard
expressions match hidden data streams. Supports comma-separated values, such
as `open,hidden`.
:param ignore_unavailable: If `false`, the request returns an error if it targets
a missing or closed index.
:param include_defaults: If `true`, return all default settings in the response.
"""
if fields in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'fields'")
__path_parts: t.Dict[str, str]
if index not in SKIP_IN_PATH and fields not in SKIP_IN_PATH:
__path_parts = {"index": _quote(index), "fields": _quote(fields)}
__path = f'/{__path_parts["index"]}/_mapping/field/{__path_parts["fields"]}'
elif fields not in SKIP_IN_PATH:
__path_parts = {"fields": _quote(fields)}
__path = f'/_mapping/field/{__path_parts["fields"]}'
else:
raise ValueError("Couldn't find a path for the given parameters")
__query: t.Dict[str, t.Any] = {}
if allow_no_indices is not None:
__query["allow_no_indices"] = allow_no_indices
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if ignore_unavailable is not None:
__query["ignore_unavailable"] = ignore_unavailable
if include_defaults is not None:
__query["include_defaults"] = include_defaults
if pretty is not None:
__query["pretty"] = pretty
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"GET",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.get_field_mapping",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def get_index_template(
self,
*,
name: t.Optional[str] = None,
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
flat_settings: t.Optional[bool] = None,
human: t.Optional[bool] = None,
include_defaults: t.Optional[bool] = None,
local: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Get index templates.
Get information about one or more index templates.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get-index-template>`_
:param name: Comma-separated list of index template names used to limit the request.
Wildcard (*) expressions are supported.
:param flat_settings: If true, returns settings in flat format.
:param include_defaults: If true, returns all relevant default configurations
for the index template.
:param local: If true, the request retrieves information from the local node
only. Defaults to false, which means information is retrieved from the master
node.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
"""
__path_parts: t.Dict[str, str]
if name not in SKIP_IN_PATH:
__path_parts = {"name": _quote(name)}
__path = f'/_index_template/{__path_parts["name"]}'
else:
__path_parts = {}
__path = "/_index_template"
__query: t.Dict[str, t.Any] = {}
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if flat_settings is not None:
__query["flat_settings"] = flat_settings
if human is not None:
__query["human"] = human
if include_defaults is not None:
__query["include_defaults"] = include_defaults
if local is not None:
__query["local"] = local
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"GET",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.get_index_template",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def get_mapping(
self,
*,
index: t.Optional[t.Union[str, t.Sequence[str]]] = None,
allow_no_indices: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
ignore_unavailable: t.Optional[bool] = None,
local: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Get mapping definitions.
For data streams, the API retrieves mappings for the stream’s backing indices.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get-mapping>`_
:param index: Comma-separated list of data streams, indices, and aliases used
to limit the request. Supports wildcards (`*`). To target all data streams
and indices, omit this parameter or use `*` or `_all`.
:param allow_no_indices: If `false`, the request returns an error if any wildcard
expression, index alias, or `_all` value targets only missing or closed indices.
This behavior applies even if the request targets other open indices.
:param expand_wildcards: Type of index that wildcard patterns can match. If the
request can target data streams, this argument determines whether wildcard
expressions match hidden data streams. Supports comma-separated values, such
as `open,hidden`.
:param ignore_unavailable: If `false`, the request returns an error if it targets
a missing or closed index.
:param local: If `true`, the request retrieves information from the local node
only.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
"""
__path_parts: t.Dict[str, str]
if index not in SKIP_IN_PATH:
__path_parts = {"index": _quote(index)}
__path = f'/{__path_parts["index"]}/_mapping'
else:
__path_parts = {}
__path = "/_mapping"
__query: t.Dict[str, t.Any] = {}
if allow_no_indices is not None:
__query["allow_no_indices"] = allow_no_indices
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if ignore_unavailable is not None:
__query["ignore_unavailable"] = ignore_unavailable
if local is not None:
__query["local"] = local
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"GET",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.get_mapping",
path_parts=__path_parts,
)
@_rewrite_parameters()
@_stability_warning(Stability.EXPERIMENTAL)
async def get_migrate_reindex_status(
self,
*,
index: t.Union[str, t.Sequence[str]],
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
pretty: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Get the migration reindexing status.</p>
<p>Get the status of a migration reindex attempt for a data stream or index.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-migration>`_
:param index: The index or data stream name.
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'index'")
__path_parts: t.Dict[str, str] = {"index": _quote(index)}
__path = f'/_migration/reindex/{__path_parts["index"]}/_status'
__query: t.Dict[str, t.Any] = {}
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if pretty is not None:
__query["pretty"] = pretty
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"GET",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.get_migrate_reindex_status",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def get_settings(
self,
*,
index: t.Optional[t.Union[str, t.Sequence[str]]] = None,
name: t.Optional[t.Union[str, t.Sequence[str]]] = None,
allow_no_indices: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
flat_settings: t.Optional[bool] = None,
human: t.Optional[bool] = None,
ignore_unavailable: t.Optional[bool] = None,
include_defaults: t.Optional[bool] = None,
local: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Get index settings.
Get setting information for one or more indices.
For data streams, it returns setting information for the stream's backing indices.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get-settings>`_
:param index: Comma-separated list of data streams, indices, and aliases used
to limit the request. Supports wildcards (`*`). To target all data streams
and indices, omit this parameter or use `*` or `_all`.
:param name: Comma-separated list or wildcard expression of settings to retrieve.
:param allow_no_indices: If `false`, the request returns an error if any wildcard
expression, index alias, or `_all` value targets only missing or closed indices.
This behavior applies even if the request targets other open indices. For
example, a request targeting `foo*,bar*` returns an error if an index starts
with foo but no index starts with `bar`.
:param expand_wildcards: Type of index that wildcard patterns can match. If the
request can target data streams, this argument determines whether wildcard
expressions match hidden data streams. Supports comma-separated values, such
as `open,hidden`.
:param flat_settings: If `true`, returns settings in flat format.
:param ignore_unavailable: If `false`, the request returns an error if it targets
a missing or closed index.
:param include_defaults: If `true`, return all default settings in the response.
:param local: If `true`, the request retrieves information from the local node
only. If `false`, information is retrieved from the master node.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
"""
__path_parts: t.Dict[str, str]
if index not in SKIP_IN_PATH and name not in SKIP_IN_PATH:
__path_parts = {"index": _quote(index), "name": _quote(name)}
__path = f'/{__path_parts["index"]}/_settings/{__path_parts["name"]}'
elif index not in SKIP_IN_PATH:
__path_parts = {"index": _quote(index)}
__path = f'/{__path_parts["index"]}/_settings'
elif name not in SKIP_IN_PATH:
__path_parts = {"name": _quote(name)}
__path = f'/_settings/{__path_parts["name"]}'
else:
__path_parts = {}
__path = "/_settings"
__query: t.Dict[str, t.Any] = {}
if allow_no_indices is not None:
__query["allow_no_indices"] = allow_no_indices
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if flat_settings is not None:
__query["flat_settings"] = flat_settings
if human is not None:
__query["human"] = human
if ignore_unavailable is not None:
__query["ignore_unavailable"] = ignore_unavailable
if include_defaults is not None:
__query["include_defaults"] = include_defaults
if local is not None:
__query["local"] = local
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"GET",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.get_settings",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def get_template(
self,
*,
name: t.Optional[t.Union[str, t.Sequence[str]]] = None,
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
flat_settings: t.Optional[bool] = None,
human: t.Optional[bool] = None,
local: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Get legacy index templates.
Get information about one or more index templates.</p>
<p>IMPORTANT: This documentation is about legacy index templates, which are deprecated and will be replaced by the composable templates introduced in Elasticsearch 7.8.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get-template>`_
:param name: Comma-separated list of index template names used to limit the request.
Wildcard (`*`) expressions are supported. To return all index templates,
omit this parameter or use a value of `_all` or `*`.
:param flat_settings: If `true`, returns settings in flat format.
:param local: If `true`, the request retrieves information from the local node
only.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
"""
__path_parts: t.Dict[str, str]
if name not in SKIP_IN_PATH:
__path_parts = {"name": _quote(name)}
__path = f'/_template/{__path_parts["name"]}'
else:
__path_parts = {}
__path = "/_template"
__query: t.Dict[str, t.Any] = {}
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if flat_settings is not None:
__query["flat_settings"] = flat_settings
if human is not None:
__query["human"] = human
if local is not None:
__query["local"] = local
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"GET",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.get_template",
path_parts=__path_parts,
)
@_rewrite_parameters(
body_name="reindex",
)
@_stability_warning(Stability.EXPERIMENTAL)
async def migrate_reindex(
self,
*,
reindex: t.Optional[t.Mapping[str, t.Any]] = None,
body: t.Optional[t.Mapping[str, t.Any]] = None,
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
pretty: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Reindex legacy backing indices.</p>
<p>Reindex all legacy backing indices for a data stream.
This operation occurs in a persistent task.
The persistent task ID is returned immediately and the reindexing work is completed in that task.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-migrate-reindex>`_
:param reindex:
"""
if reindex is None and body is None:
raise ValueError(
"Empty value passed for parameters 'reindex' and 'body', one of them should be set."
)
elif reindex is not None and body is not None:
raise ValueError("Cannot set both 'reindex' and 'body'")
__path_parts: t.Dict[str, str] = {}
__path = "/_migration/reindex"
__query: t.Dict[str, t.Any] = {}
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if pretty is not None:
__query["pretty"] = pretty
__body = reindex if reindex is not None else body
__headers = {"accept": "application/json", "content-type": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"POST",
__path,
params=__query,
headers=__headers,
body=__body,
endpoint_id="indices.migrate_reindex",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def migrate_to_data_stream(
self,
*,
name: str,
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Convert an index alias to a data stream.
Converts an index alias to a data stream.
You must have a matching index template that is data stream enabled.
The alias must meet the following criteria:
The alias must have a write index;
All indices for the alias must have a <code>@timestamp</code> field mapping of a <code>date</code> or <code>date_nanos</code> field type;
The alias must not have any filters;
The alias must not use custom routing.
If successful, the request removes the alias and creates a data stream with the same name.
The indices for the alias become hidden backing indices for the stream.
The write index for the alias becomes the write index for the stream.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-migrate-to-data-stream>`_
:param name: Name of the index alias to convert to a data stream.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
:param timeout: Period to wait for a response. If no response is received before
the timeout expires, the request fails and returns an error.
"""
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'name'")
__path_parts: t.Dict[str, str] = {"name": _quote(name)}
__path = f'/_data_stream/_migrate/{__path_parts["name"]}'
__query: t.Dict[str, t.Any] = {}
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
if timeout is not None:
__query["timeout"] = timeout
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"POST",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.migrate_to_data_stream",
path_parts=__path_parts,
)
@_rewrite_parameters(
body_fields=("actions",),
)
async def modify_data_stream(
self,
*,
actions: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
pretty: t.Optional[bool] = None,
body: t.Optional[t.Dict[str, t.Any]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Update data streams.
Performs one or more data stream modification actions in a single atomic operation.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-modify-data-stream>`_
:param actions: Actions to perform.
"""
if actions is None and body is None:
raise ValueError("Empty value passed for parameter 'actions'")
__path_parts: t.Dict[str, str] = {}
__path = "/_data_stream/_modify"
__query: t.Dict[str, t.Any] = {}
__body: t.Dict[str, t.Any] = body if body is not None else {}
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if pretty is not None:
__query["pretty"] = pretty
if not __body:
if actions is not None:
__body["actions"] = actions
__headers = {"accept": "application/json", "content-type": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"POST",
__path,
params=__query,
headers=__headers,
body=__body,
endpoint_id="indices.modify_data_stream",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def open(
self,
*,
index: t.Union[str, t.Sequence[str]],
allow_no_indices: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
ignore_unavailable: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
wait_for_active_shards: t.Optional[
t.Union[int, t.Union[str, t.Literal["all", "index-setting"]]]
] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Open a closed index.
For data streams, the API opens any closed backing indices.</p>
<p>A closed index is blocked for read/write operations and does not allow all operations that opened indices allow.
It is not possible to index documents or to search for documents in a closed index.
This allows closed indices to not have to maintain internal data structures for indexing or searching documents, resulting in a smaller overhead on the cluster.</p>
<p>When opening or closing an index, the master is responsible for restarting the index shards to reflect the new state of the index.
The shards will then go through the normal recovery process.
The data of opened or closed indices is automatically replicated by the cluster to ensure that enough shard copies are safely kept around at all times.</p>
<p>You can open and close multiple indices.
An error is thrown if the request explicitly refers to a missing index.
This behavior can be turned off by using the <code>ignore_unavailable=true</code> parameter.</p>
<p>By default, you must explicitly name the indices you are opening or closing.
To open or close indices with <code>_all</code>, <code>*</code>, or other wildcard expressions, change the <code>action.destructive_requires_name</code> setting to <code>false</code>.
This setting can also be changed with the cluster update settings API.</p>
<p>Closed indices consume a significant amount of disk-space which can cause problems in managed environments.
Closing indices can be turned off with the cluster settings API by setting <code>cluster.indices.close.enable</code> to <code>false</code>.</p>
<p>Because opening or closing an index allocates its shards, the <code>wait_for_active_shards</code> setting on index creation applies to the <code>_open</code> and <code>_close</code> index actions as well.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-open>`_
:param index: Comma-separated list of data streams, indices, and aliases used
to limit the request. Supports wildcards (`*`). By default, you must explicitly
name the indices you using to limit the request. To limit a request using
`_all`, `*`, or other wildcard expressions, change the `action.destructive_requires_name`
setting to false. You can update this setting in the `elasticsearch.yml`
file or using the cluster update settings API.
:param allow_no_indices: If `false`, the request returns an error if any wildcard
expression, index alias, or `_all` value targets only missing or closed indices.
This behavior applies even if the request targets other open indices.
:param expand_wildcards: Type of index that wildcard patterns can match. If the
request can target data streams, this argument determines whether wildcard
expressions match hidden data streams. Supports comma-separated values, such
as `open,hidden`.
:param ignore_unavailable: If `false`, the request returns an error if it targets
a missing or closed index.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
:param timeout: Period to wait for a response. If no response is received before
the timeout expires, the request fails and returns an error.
:param wait_for_active_shards: The number of shard copies that must be active
before proceeding with the operation. Set to `all` or any positive integer
up to the total number of shards in the index (`number_of_replicas+1`).
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'index'")
__path_parts: t.Dict[str, str] = {"index": _quote(index)}
__path = f'/{__path_parts["index"]}/_open'
__query: t.Dict[str, t.Any] = {}
if allow_no_indices is not None:
__query["allow_no_indices"] = allow_no_indices
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if ignore_unavailable is not None:
__query["ignore_unavailable"] = ignore_unavailable
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
if timeout is not None:
__query["timeout"] = timeout
if wait_for_active_shards is not None:
__query["wait_for_active_shards"] = wait_for_active_shards
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"POST",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.open",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def promote_data_stream(
self,
*,
name: str,
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Promote a data stream.
Promote a data stream from a replicated data stream managed by cross-cluster replication (CCR) to a regular data stream.</p>
<p>With CCR auto following, a data stream from a remote cluster can be replicated to the local cluster.
These data streams can't be rolled over in the local cluster.
These replicated data streams roll over only if the upstream data stream rolls over.
In the event that the remote cluster is no longer available, the data stream in the local cluster can be promoted to a regular data stream, which allows these data streams to be rolled over in the local cluster.</p>
<p>NOTE: When promoting a data stream, ensure the local cluster has a data stream enabled index template that matches the data stream.
If this is missing, the data stream will not be able to roll over until a matching index template is created.
This will affect the lifecycle management of the data stream and interfere with the data stream size and retention.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-promote-data-stream>`_
:param name: The name of the data stream
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
"""
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'name'")
__path_parts: t.Dict[str, str] = {"name": _quote(name)}
__path = f'/_data_stream/_promote/{__path_parts["name"]}'
__query: t.Dict[str, t.Any] = {}
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"POST",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.promote_data_stream",
path_parts=__path_parts,
)
@_rewrite_parameters(
body_fields=(
"filter",
"index_routing",
"is_write_index",
"routing",
"search_routing",
),
)
async def put_alias(
self,
*,
index: t.Union[str, t.Sequence[str]],
name: str,
error_trace: t.Optional[bool] = None,
filter: t.Optional[t.Mapping[str, t.Any]] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
index_routing: t.Optional[str] = None,
is_write_index: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
routing: t.Optional[str] = None,
search_routing: t.Optional[str] = None,
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
body: t.Optional[t.Dict[str, t.Any]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Create or update an alias.
Adds a data stream or index to an alias.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-alias>`_
:param index: Comma-separated list of data streams or indices to add. Supports
wildcards (`*`). Wildcard patterns that match both data streams and indices
return an error.
:param name: Alias to update. If the alias doesn’t exist, the request creates
it. Index alias names support date math.
:param filter: Query used to limit documents the alias can access.
:param index_routing: Value used to route indexing operations to a specific shard.
If specified, this overwrites the `routing` value for indexing operations.
Data stream aliases don’t support this parameter.
:param is_write_index: If `true`, sets the write index or data stream for the
alias. If an alias points to multiple indices or data streams and `is_write_index`
isn’t set, the alias rejects write requests. If an index alias points to
one index and `is_write_index` isn’t set, the index automatically acts as
the write index. Data stream aliases don’t automatically set a write data
stream, even if the alias points to one data stream.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
:param routing: Value used to route indexing and search operations to a specific
shard. Data stream aliases don’t support this parameter.
:param search_routing: Value used to route search operations to a specific shard.
If specified, this overwrites the `routing` value for search operations.
Data stream aliases don’t support this parameter.
:param timeout: Period to wait for a response. If no response is received before
the timeout expires, the request fails and returns an error.
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'index'")
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'name'")
__path_parts: t.Dict[str, str] = {"index": _quote(index), "name": _quote(name)}
__path = f'/{__path_parts["index"]}/_alias/{__path_parts["name"]}'
__query: t.Dict[str, t.Any] = {}
__body: t.Dict[str, t.Any] = body if body is not None else {}
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
if timeout is not None:
__query["timeout"] = timeout
if not __body:
if filter is not None:
__body["filter"] = filter
if index_routing is not None:
__body["index_routing"] = index_routing
if is_write_index is not None:
__body["is_write_index"] = is_write_index
if routing is not None:
__body["routing"] = routing
if search_routing is not None:
__body["search_routing"] = search_routing
if not __body:
__body = None # type: ignore[assignment]
__headers = {"accept": "application/json"}
if __body is not None:
__headers["content-type"] = "application/json"
return await self.perform_request( # type: ignore[return-value]
"PUT",
__path,
params=__query,
headers=__headers,
body=__body,
endpoint_id="indices.put_alias",
path_parts=__path_parts,
)
@_rewrite_parameters(
body_fields=("data_retention", "downsampling", "enabled"),
)
async def put_data_lifecycle(
self,
*,
name: t.Union[str, t.Sequence[str]],
data_retention: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
downsampling: t.Optional[t.Mapping[str, t.Any]] = None,
enabled: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
body: t.Optional[t.Dict[str, t.Any]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Update data stream lifecycles.
Update the data stream lifecycle of the specified data streams.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-data-lifecycle>`_
:param name: Comma-separated list of data streams used to limit the request.
Supports wildcards (`*`). To target all data streams use `*` or `_all`.
:param data_retention: If defined, every document added to this data stream will
be stored at least for this time frame. Any time after this duration the
document could be deleted. When empty, every document in this data stream
will be stored indefinitely.
:param downsampling: The downsampling configuration to execute for the managed
backing index after rollover.
:param enabled: If defined, it turns data stream lifecycle on/off (`true`/`false`)
for this data stream. A data stream lifecycle that's disabled (enabled: `false`)
will have no effect on the data stream.
:param expand_wildcards: Type of data stream that wildcard patterns can match.
Supports comma-separated values, such as `open,hidden`.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
:param timeout: Period to wait for a response. If no response is received before
the timeout expires, the request fails and returns an error.
"""
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'name'")
__path_parts: t.Dict[str, str] = {"name": _quote(name)}
__path = f'/_data_stream/{__path_parts["name"]}/_lifecycle'
__query: t.Dict[str, t.Any] = {}
__body: t.Dict[str, t.Any] = body if body is not None else {}
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
if timeout is not None:
__query["timeout"] = timeout
if not __body:
if data_retention is not None:
__body["data_retention"] = data_retention
if downsampling is not None:
__body["downsampling"] = downsampling
if enabled is not None:
__body["enabled"] = enabled
if not __body:
__body = None # type: ignore[assignment]
__headers = {"accept": "application/json"}
if __body is not None:
__headers["content-type"] = "application/json"
return await self.perform_request( # type: ignore[return-value]
"PUT",
__path,
params=__query,
headers=__headers,
body=__body,
endpoint_id="indices.put_data_lifecycle",
path_parts=__path_parts,
)
@_rewrite_parameters(
body_fields=("failure_store",),
)
async def put_data_stream_options(
self,
*,
name: t.Union[str, t.Sequence[str]],
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
failure_store: t.Optional[t.Mapping[str, t.Any]] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
body: t.Optional[t.Dict[str, t.Any]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Update data stream options.
Update the data stream options of the specified data streams.</p>
`<https://www.elastic.co/guide/en/elasticsearch/reference/9.1/index.html>`_
:param name: Comma-separated list of data streams used to limit the request.
Supports wildcards (`*`). To target all data streams use `*` or `_all`.
:param expand_wildcards: Type of data stream that wildcard patterns can match.
Supports comma-separated values, such as `open,hidden`.
:param failure_store: If defined, it will update the failure store configuration
of every data stream resolved by the name expression.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
:param timeout: Period to wait for a response. If no response is received before
the timeout expires, the request fails and returns an error.
"""
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'name'")
__path_parts: t.Dict[str, str] = {"name": _quote(name)}
__path = f'/_data_stream/{__path_parts["name"]}/_options'
__query: t.Dict[str, t.Any] = {}
__body: t.Dict[str, t.Any] = body if body is not None else {}
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
if timeout is not None:
__query["timeout"] = timeout
if not __body:
if failure_store is not None:
__body["failure_store"] = failure_store
if not __body:
__body = None # type: ignore[assignment]
__headers = {"accept": "application/json"}
if __body is not None:
__headers["content-type"] = "application/json"
return await self.perform_request( # type: ignore[return-value]
"PUT",
__path,
params=__query,
headers=__headers,
body=__body,
endpoint_id="indices.put_data_stream_options",
path_parts=__path_parts,
)
@_rewrite_parameters(
body_name="settings",
)
async def put_data_stream_settings(
self,
*,
name: t.Union[str, t.Sequence[str]],
settings: t.Optional[t.Mapping[str, t.Any]] = None,
body: t.Optional[t.Mapping[str, t.Any]] = None,
dry_run: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Update data stream settings.</p>
<p>This API can be used to override settings on specific data streams. These overrides will take precedence over what
is specified in the template that the data stream matches. To prevent your data stream from getting into an invalid state,
only certain settings are allowed. If possible, the setting change is applied to all
backing indices. Otherwise, it will be applied when the data stream is next rolled over.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-data-stream-settings>`_
:param name: A comma-separated list of data streams or data stream patterns.
:param settings:
:param dry_run: If `true`, the request does not actually change the settings
on any data streams or indices. Instead, it simulates changing the settings
and reports back to the user what would have happened had these settings
actually been applied.
:param master_timeout: The period to wait for a connection to the master node.
If no response is received before the timeout expires, the request fails
and returns an error.
:param timeout: The period to wait for a response. If no response is received
before the timeout expires, the request fails and returns an error.
"""
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'name'")
if settings is None and body is None:
raise ValueError(
"Empty value passed for parameters 'settings' and 'body', one of them should be set."
)
elif settings is not None and body is not None:
raise ValueError("Cannot set both 'settings' and 'body'")
__path_parts: t.Dict[str, str] = {"name": _quote(name)}
__path = f'/_data_stream/{__path_parts["name"]}/_settings'
__query: t.Dict[str, t.Any] = {}
if dry_run is not None:
__query["dry_run"] = dry_run
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
if timeout is not None:
__query["timeout"] = timeout
__body = settings if settings is not None else body
__headers = {"accept": "application/json", "content-type": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"PUT",
__path,
params=__query,
headers=__headers,
body=__body,
endpoint_id="indices.put_data_stream_settings",
path_parts=__path_parts,
)
@_rewrite_parameters(
body_fields=(
"allow_auto_create",
"composed_of",
"data_stream",
"deprecated",
"ignore_missing_component_templates",
"index_patterns",
"meta",
"priority",
"template",
"version",
),
parameter_aliases={"_meta": "meta"},
)
async def put_index_template(
self,
*,
name: str,
allow_auto_create: t.Optional[bool] = None,
cause: t.Optional[str] = None,
composed_of: t.Optional[t.Sequence[str]] = None,
create: t.Optional[bool] = None,
data_stream: t.Optional[t.Mapping[str, t.Any]] = None,
deprecated: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
ignore_missing_component_templates: t.Optional[t.Sequence[str]] = None,
index_patterns: t.Optional[t.Union[str, t.Sequence[str]]] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
meta: t.Optional[t.Mapping[str, t.Any]] = None,
pretty: t.Optional[bool] = None,
priority: t.Optional[int] = None,
template: t.Optional[t.Mapping[str, t.Any]] = None,
version: t.Optional[int] = None,
body: t.Optional[t.Dict[str, t.Any]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Create or update an index template.
Index templates define settings, mappings, and aliases that can be applied automatically to new indices.</p>
<p>Elasticsearch applies templates to new indices based on an wildcard pattern that matches the index name.
Index templates are applied during data stream or index creation.
For data streams, these settings and mappings are applied when the stream's backing indices are created.
Settings and mappings specified in a create index API request override any settings or mappings specified in an index template.
Changes to index templates do not affect existing indices, including the existing backing indices of a data stream.</p>
<p>You can use C-style <code>/* *\\/</code> block comments in index templates.
You can include comments anywhere in the request body, except before the opening curly bracket.</p>
<p><strong>Multiple matching templates</strong></p>
<p>If multiple index templates match the name of a new index or data stream, the template with the highest priority is used.</p>
<p>Multiple templates with overlapping index patterns at the same priority are not allowed and an error will be thrown when attempting to create a template matching an existing index template at identical priorities.</p>
<p><strong>Composing aliases, mappings, and settings</strong></p>
<p>When multiple component templates are specified in the <code>composed_of</code> field for an index template, they are merged in the order specified, meaning that later component templates override earlier component templates.
Any mappings, settings, or aliases from the parent index template are merged in next.
Finally, any configuration on the index request itself is merged.
Mapping definitions are merged recursively, which means that later mapping components can introduce new field mappings and update the mapping configuration.
If a field mapping is already contained in an earlier component, its definition will be completely overwritten by the later one.
This recursive merging strategy applies not only to field mappings, but also root options like <code>dynamic_templates</code> and <code>meta</code>.
If an earlier component contains a <code>dynamic_templates</code> block, then by default new <code>dynamic_templates</code> entries are appended onto the end.
If an entry already exists with the same key, then it is overwritten by the new definition.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-index-template>`_
:param name: Index or template name
:param allow_auto_create: This setting overrides the value of the `action.auto_create_index`
cluster setting. If set to `true` in a template, then indices can be automatically
created using that template even if auto-creation of indices is disabled
via `actions.auto_create_index`. If set to `false`, then indices or data
streams matching the template must always be explicitly created, and may
never be automatically created.
:param cause: User defined reason for creating/updating the index template
:param composed_of: An ordered list of component template names. Component templates
are merged in the order specified, meaning that the last component template
specified has the highest precedence.
:param create: If `true`, this request cannot replace or update existing index
templates.
:param data_stream: If this object is included, the template is used to create
data streams and their backing indices. Supports an empty object. Data streams
require a matching index template with a `data_stream` object.
:param deprecated: Marks this index template as deprecated. When creating or
updating a non-deprecated index template that uses deprecated components,
Elasticsearch will emit a deprecation warning.
:param ignore_missing_component_templates: The configuration option ignore_missing_component_templates
can be used when an index template references a component template that might
not exist
:param index_patterns: Name of the index template to create.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
:param meta: Optional user metadata about the index template. It may have any
contents. It is not automatically generated or used by Elasticsearch. This
user-defined object is stored in the cluster state, so keeping it short is
preferable To unset the metadata, replace the template without specifying
it.
:param priority: Priority to determine index template precedence when a new data
stream or index is created. The index template with the highest priority
is chosen. If no priority is specified the template is treated as though
it is of priority 0 (lowest priority). This number is not automatically generated
by Elasticsearch.
:param template: Template to be applied. It may optionally include an `aliases`,
`mappings`, or `settings` configuration.
:param version: Version number used to manage index templates externally. This
number is not automatically generated by Elasticsearch. External systems
can use these version numbers to simplify template management. To unset a
version, replace the template without specifying one.
"""
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'name'")
__path_parts: t.Dict[str, str] = {"name": _quote(name)}
__path = f'/_index_template/{__path_parts["name"]}'
__query: t.Dict[str, t.Any] = {}
__body: t.Dict[str, t.Any] = body if body is not None else {}
if cause is not None:
__query["cause"] = cause
if create is not None:
__query["create"] = create
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
if not __body:
if allow_auto_create is not None:
__body["allow_auto_create"] = allow_auto_create
if composed_of is not None:
__body["composed_of"] = composed_of
if data_stream is not None:
__body["data_stream"] = data_stream
if deprecated is not None:
__body["deprecated"] = deprecated
if ignore_missing_component_templates is not None:
__body["ignore_missing_component_templates"] = (
ignore_missing_component_templates
)
if index_patterns is not None:
__body["index_patterns"] = index_patterns
if meta is not None:
__body["_meta"] = meta
if priority is not None:
__body["priority"] = priority
if template is not None:
__body["template"] = template
if version is not None:
__body["version"] = version
__headers = {"accept": "application/json", "content-type": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"PUT",
__path,
params=__query,
headers=__headers,
body=__body,
endpoint_id="indices.put_index_template",
path_parts=__path_parts,
)
@_rewrite_parameters(
body_fields=(
"date_detection",
"dynamic",
"dynamic_date_formats",
"dynamic_templates",
"field_names",
"meta",
"numeric_detection",
"properties",
"routing",
"runtime",
"source",
),
parameter_aliases={
"_field_names": "field_names",
"_meta": "meta",
"_routing": "routing",
"_source": "source",
},
)
async def put_mapping(
self,
*,
index: t.Union[str, t.Sequence[str]],
allow_no_indices: t.Optional[bool] = None,
date_detection: t.Optional[bool] = None,
dynamic: t.Optional[
t.Union[str, t.Literal["false", "runtime", "strict", "true"]]
] = None,
dynamic_date_formats: t.Optional[t.Sequence[str]] = None,
dynamic_templates: t.Optional[
t.Sequence[t.Mapping[str, t.Mapping[str, t.Any]]]
] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
field_names: t.Optional[t.Mapping[str, t.Any]] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
ignore_unavailable: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
meta: t.Optional[t.Mapping[str, t.Any]] = None,
numeric_detection: t.Optional[bool] = None,
pretty: t.Optional[bool] = None,
properties: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
routing: t.Optional[t.Mapping[str, t.Any]] = None,
runtime: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
source: t.Optional[t.Mapping[str, t.Any]] = None,
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
write_index_only: t.Optional[bool] = None,
body: t.Optional[t.Dict[str, t.Any]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Update field mappings.
Add new fields to an existing data stream or index.
You can use the update mapping API to:</p>
<ul>
<li>Add a new field to an existing index</li>
<li>Update mappings for multiple indices in a single request</li>
<li>Add new properties to an object field</li>
<li>Enable multi-fields for an existing field</li>
<li>Update supported mapping parameters</li>
<li>Change a field's mapping using reindexing</li>
<li>Rename a field using a field alias</li>
</ul>
<p>Learn how to use the update mapping API with practical examples in the <a href="https://www.elastic.co/docs//manage-data/data-store/mapping/update-mappings-examples">Update mapping API examples</a> guide.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-mapping>`_
:param index: A comma-separated list of index names the mapping should be added
to (supports wildcards); use `_all` or omit to add the mapping on all indices.
:param allow_no_indices: If `false`, the request returns an error if any wildcard
expression, index alias, or `_all` value targets only missing or closed indices.
This behavior applies even if the request targets other open indices.
:param date_detection: Controls whether dynamic date detection is enabled.
:param dynamic: Controls whether new fields are added dynamically.
:param dynamic_date_formats: If date detection is enabled then new string fields
are checked against 'dynamic_date_formats' and if the value matches then
a new date field is added instead of string.
:param dynamic_templates: Specify dynamic templates for the mapping.
:param expand_wildcards: Type of index that wildcard patterns can match. If the
request can target data streams, this argument determines whether wildcard
expressions match hidden data streams. Supports comma-separated values, such
as `open,hidden`.
:param field_names: Control whether field names are enabled for the index.
:param ignore_unavailable: If `false`, the request returns an error if it targets
a missing or closed index.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
:param meta: A mapping type can have custom meta data associated with it. These
are not used at all by Elasticsearch, but can be used to store application-specific
metadata.
:param numeric_detection: Automatically map strings into numeric data types for
all fields.
:param properties: Mapping for a field. For new fields, this mapping can include:
- Field name - Field data type - Mapping parameters
:param routing: Enable making a routing value required on indexed documents.
:param runtime: Mapping of runtime fields for the index.
:param source: Control whether the _source field is enabled on the index.
:param timeout: Period to wait for a response. If no response is received before
the timeout expires, the request fails and returns an error.
:param write_index_only: If `true`, the mappings are applied only to the current
write index for the target.
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'index'")
__path_parts: t.Dict[str, str] = {"index": _quote(index)}
__path = f'/{__path_parts["index"]}/_mapping'
__query: t.Dict[str, t.Any] = {}
__body: t.Dict[str, t.Any] = body if body is not None else {}
if allow_no_indices is not None:
__query["allow_no_indices"] = allow_no_indices
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if ignore_unavailable is not None:
__query["ignore_unavailable"] = ignore_unavailable
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
if timeout is not None:
__query["timeout"] = timeout
if write_index_only is not None:
__query["write_index_only"] = write_index_only
if not __body:
if date_detection is not None:
__body["date_detection"] = date_detection
if dynamic is not None:
__body["dynamic"] = dynamic
if dynamic_date_formats is not None:
__body["dynamic_date_formats"] = dynamic_date_formats
if dynamic_templates is not None:
__body["dynamic_templates"] = dynamic_templates
if field_names is not None:
__body["_field_names"] = field_names
if meta is not None:
__body["_meta"] = meta
if numeric_detection is not None:
__body["numeric_detection"] = numeric_detection
if properties is not None:
__body["properties"] = properties
if routing is not None:
__body["_routing"] = routing
if runtime is not None:
__body["runtime"] = runtime
if source is not None:
__body["_source"] = source
__headers = {"accept": "application/json", "content-type": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"PUT",
__path,
params=__query,
headers=__headers,
body=__body,
endpoint_id="indices.put_mapping",
path_parts=__path_parts,
)
@_rewrite_parameters(
body_name="settings",
)
async def put_settings(
self,
*,
settings: t.Optional[t.Mapping[str, t.Any]] = None,
body: t.Optional[t.Mapping[str, t.Any]] = None,
index: t.Optional[t.Union[str, t.Sequence[str]]] = None,
allow_no_indices: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
flat_settings: t.Optional[bool] = None,
human: t.Optional[bool] = None,
ignore_unavailable: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
preserve_existing: t.Optional[bool] = None,
pretty: t.Optional[bool] = None,
reopen: t.Optional[bool] = None,
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Update index settings.
Changes dynamic index settings in real time.
For data streams, index setting changes are applied to all backing indices by default.</p>
<p>To revert a setting to the default value, use a null value.
The list of per-index settings that can be updated dynamically on live indices can be found in index settings documentation.
To preserve existing settings from being updated, set the <code>preserve_existing</code> parameter to <code>true</code>.</p>
<p>For performance optimization during bulk indexing, you can disable the refresh interval.
Refer to <a href="https://www.elastic.co/docs/deploy-manage/production-guidance/optimize-performance/indexing-speed#disable-refresh-interval">disable refresh interval</a> for an example.
There are multiple valid ways to represent index settings in the request body. You can specify only the setting, for example:</p>
<pre><code>{
"number_of_replicas": 1
}
</code></pre>
<p>Or you can use an <code>index</code> setting object:</p>
<pre><code>{
"index": {
"number_of_replicas": 1
}
}
</code></pre>
<p>Or you can use dot annotation:</p>
<pre><code>{
"index.number_of_replicas": 1
}
</code></pre>
<p>Or you can embed any of the aforementioned options in a <code>settings</code> object. For example:</p>
<pre><code>{
"settings": {
"index": {
"number_of_replicas": 1
}
}
}
</code></pre>
<p>NOTE: You can only define new analyzers on closed indices.
To add an analyzer, you must close the index, define the analyzer, and reopen the index.
You cannot close the write index of a data stream.
To update the analyzer for a data stream's write index and future backing indices, update the analyzer in the index template used by the stream.
Then roll over the data stream to apply the new analyzer to the stream's write index and future backing indices.
This affects searches and any new data added to the stream after the rollover.
However, it does not affect the data stream's backing indices or their existing data.
To change the analyzer for existing backing indices, you must create a new data stream and reindex your data into it.
Refer to <a href="https://www.elastic.co/docs/manage-data/data-store/text-analysis/specify-an-analyzer#update-analyzers-on-existing-indices">updating analyzers on existing indices</a> for step-by-step examples.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-settings>`_
:param settings:
:param index: Comma-separated list of data streams, indices, and aliases used
to limit the request. Supports wildcards (`*`). To target all data streams
and indices, omit this parameter or use `*` or `_all`.
:param allow_no_indices: If `false`, the request returns an error if any wildcard
expression, index alias, or `_all` value targets only missing or closed indices.
This behavior applies even if the request targets other open indices. For
example, a request targeting `foo*,bar*` returns an error if an index starts
with `foo` but no index starts with `bar`.
:param expand_wildcards: Type of index that wildcard patterns can match. If the
request can target data streams, this argument determines whether wildcard
expressions match hidden data streams. Supports comma-separated values, such
as `open,hidden`.
:param flat_settings: If `true`, returns settings in flat format.
:param ignore_unavailable: If `true`, returns settings in flat format.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
:param preserve_existing: If `true`, existing index settings remain unchanged.
:param reopen: Whether to close and reopen the index to apply non-dynamic settings.
If set to `true` the indices to which the settings are being applied will
be closed temporarily and then reopened in order to apply the changes.
:param timeout: Period to wait for a response. If no response is received before
the timeout expires, the request fails and returns an error.
"""
if settings is None and body is None:
raise ValueError(
"Empty value passed for parameters 'settings' and 'body', one of them should be set."
)
elif settings is not None and body is not None:
raise ValueError("Cannot set both 'settings' and 'body'")
__path_parts: t.Dict[str, str]
if index not in SKIP_IN_PATH:
__path_parts = {"index": _quote(index)}
__path = f'/{__path_parts["index"]}/_settings'
else:
__path_parts = {}
__path = "/_settings"
__query: t.Dict[str, t.Any] = {}
if allow_no_indices is not None:
__query["allow_no_indices"] = allow_no_indices
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if flat_settings is not None:
__query["flat_settings"] = flat_settings
if human is not None:
__query["human"] = human
if ignore_unavailable is not None:
__query["ignore_unavailable"] = ignore_unavailable
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if preserve_existing is not None:
__query["preserve_existing"] = preserve_existing
if pretty is not None:
__query["pretty"] = pretty
if reopen is not None:
__query["reopen"] = reopen
if timeout is not None:
__query["timeout"] = timeout
__body = settings if settings is not None else body
__headers = {"accept": "application/json", "content-type": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"PUT",
__path,
params=__query,
headers=__headers,
body=__body,
endpoint_id="indices.put_settings",
path_parts=__path_parts,
)
@_rewrite_parameters(
body_fields=(
"aliases",
"index_patterns",
"mappings",
"order",
"settings",
"version",
),
)
async def put_template(
self,
*,
name: str,
aliases: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
cause: t.Optional[str] = None,
create: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
index_patterns: t.Optional[t.Union[str, t.Sequence[str]]] = None,
mappings: t.Optional[t.Mapping[str, t.Any]] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
order: t.Optional[int] = None,
pretty: t.Optional[bool] = None,
settings: t.Optional[t.Mapping[str, t.Any]] = None,
version: t.Optional[int] = None,
body: t.Optional[t.Dict[str, t.Any]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Create or update a legacy index template.
Index templates define settings, mappings, and aliases that can be applied automatically to new indices.
Elasticsearch applies templates to new indices based on an index pattern that matches the index name.</p>
<p>IMPORTANT: This documentation is about legacy index templates, which are deprecated and will be replaced by the composable templates introduced in Elasticsearch 7.8.</p>
<p>Composable templates always take precedence over legacy templates.
If no composable template matches a new index, matching legacy templates are applied according to their order.</p>
<p>Index templates are only applied during index creation.
Changes to index templates do not affect existing indices.
Settings and mappings specified in create index API requests override any settings or mappings specified in an index template.</p>
<p>You can use C-style <code>/* *\\/</code> block comments in index templates.
You can include comments anywhere in the request body, except before the opening curly bracket.</p>
<p><strong>Indices matching multiple templates</strong></p>
<p>Multiple index templates can potentially match an index, in this case, both the settings and mappings are merged into the final configuration of the index.
The order of the merging can be controlled using the order parameter, with lower order being applied first, and higher orders overriding them.
NOTE: Multiple matching templates with the same order value will result in a non-deterministic merging order.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-template>`_
:param name: The name of the template
:param aliases: Aliases for the index.
:param cause: User defined reason for creating/updating the index template
:param create: If true, this request cannot replace or update existing index
templates.
:param index_patterns: Array of wildcard expressions used to match the names
of indices during creation.
:param mappings: Mapping for fields in the index.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
:param order: Order in which Elasticsearch applies this template if index matches
multiple templates. Templates with lower 'order' values are merged first.
Templates with higher 'order' values are merged later, overriding templates
with lower values.
:param settings: Configuration options for the index.
:param version: Version number used to manage index templates externally. This
number is not automatically generated by Elasticsearch. To unset a version,
replace the template without specifying one.
"""
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'name'")
__path_parts: t.Dict[str, str] = {"name": _quote(name)}
__path = f'/_template/{__path_parts["name"]}'
__query: t.Dict[str, t.Any] = {}
__body: t.Dict[str, t.Any] = body if body is not None else {}
if cause is not None:
__query["cause"] = cause
if create is not None:
__query["create"] = create
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
if not __body:
if aliases is not None:
__body["aliases"] = aliases
if index_patterns is not None:
__body["index_patterns"] = index_patterns
if mappings is not None:
__body["mappings"] = mappings
if order is not None:
__body["order"] = order
if settings is not None:
__body["settings"] = settings
if version is not None:
__body["version"] = version
__headers = {"accept": "application/json", "content-type": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"PUT",
__path,
params=__query,
headers=__headers,
body=__body,
endpoint_id="indices.put_template",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def recovery(
self,
*,
index: t.Optional[t.Union[str, t.Sequence[str]]] = None,
active_only: t.Optional[bool] = None,
allow_no_indices: t.Optional[bool] = None,
detailed: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
ignore_unavailable: t.Optional[bool] = None,
pretty: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Get index recovery information.
Get information about ongoing and completed shard recoveries for one or more indices.
For data streams, the API returns information for the stream's backing indices.</p>
<p>All recoveries, whether ongoing or complete, are kept in the cluster state and may be reported on at any time.</p>
<p>Shard recovery is the process of initializing a shard copy, such as restoring a primary shard from a snapshot or creating a replica shard from a primary shard.
When a shard recovery completes, the recovered shard is available for search and indexing.</p>
<p>Recovery automatically occurs during the following processes:</p>
<ul>
<li>When creating an index for the first time.</li>
<li>When a node rejoins the cluster and starts up any missing primary shard copies using the data that it holds in its data path.</li>
<li>Creation of new replica shard copies from the primary.</li>
<li>Relocation of a shard copy to a different node in the same cluster.</li>
<li>A snapshot restore operation.</li>
<li>A clone, shrink, or split operation.</li>
</ul>
<p>You can determine the cause of a shard recovery using the recovery or cat recovery APIs.</p>
<p>The index recovery API reports information about completed recoveries only for shard copies that currently exist in the cluster.
It only reports the last recovery for each shard copy and does not report historical information about earlier recoveries, nor does it report information about the recoveries of shard copies that no longer exist.
This means that if a shard copy completes a recovery and then Elasticsearch relocates it onto a different node then the information about the original recovery will not be shown in the recovery API.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-recovery>`_
:param index: Comma-separated list of data streams, indices, and aliases used
to limit the request. Supports wildcards (`*`). To target all data streams
and indices, omit this parameter or use `*` or `_all`.
:param active_only: If `true`, the response only includes ongoing shard recoveries.
:param allow_no_indices: If `false`, the request returns an error if any wildcard
expression, index alias, or `_all` value targets only missing or closed indices.
This behavior applies even if the request targets other open indices.
:param detailed: If `true`, the response includes detailed information about
shard recoveries.
:param expand_wildcards: Type of index that wildcard patterns can match. If the
request can target data streams, this argument determines whether wildcard
expressions match hidden data streams. Supports comma-separated values, such
as `open,hidden`.
:param ignore_unavailable: If `false`, the request returns an error if it targets
a missing or closed index.
"""
__path_parts: t.Dict[str, str]
if index not in SKIP_IN_PATH:
__path_parts = {"index": _quote(index)}
__path = f'/{__path_parts["index"]}/_recovery'
else:
__path_parts = {}
__path = "/_recovery"
__query: t.Dict[str, t.Any] = {}
if active_only is not None:
__query["active_only"] = active_only
if allow_no_indices is not None:
__query["allow_no_indices"] = allow_no_indices
if detailed is not None:
__query["detailed"] = detailed
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if ignore_unavailable is not None:
__query["ignore_unavailable"] = ignore_unavailable
if pretty is not None:
__query["pretty"] = pretty
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"GET",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.recovery",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def refresh(
self,
*,
index: t.Optional[t.Union[str, t.Sequence[str]]] = None,
allow_no_indices: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
ignore_unavailable: t.Optional[bool] = None,
pretty: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Refresh an index.
A refresh makes recent operations performed on one or more indices available for search.
For data streams, the API runs the refresh operation on the stream’s backing indices.</p>
<p>By default, Elasticsearch periodically refreshes indices every second, but only on indices that have received one search request or more in the last 30 seconds.
You can change this default interval with the <code>index.refresh_interval</code> setting.</p>
<p>Refresh requests are synchronous and do not return a response until the refresh operation completes.</p>
<p>Refreshes are resource-intensive.
To ensure good cluster performance, it's recommended to wait for Elasticsearch's periodic refresh rather than performing an explicit refresh when possible.</p>
<p>If your application workflow indexes documents and then runs a search to retrieve the indexed document, it's recommended to use the index API's <code>refresh=wait_for</code> query parameter option.
This option ensures the indexing operation waits for a periodic refresh before running the search.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-refresh>`_
:param index: Comma-separated list of data streams, indices, and aliases used
to limit the request. Supports wildcards (`*`). To target all data streams
and indices, omit this parameter or use `*` or `_all`.
:param allow_no_indices: If `false`, the request returns an error if any wildcard
expression, index alias, or `_all` value targets only missing or closed indices.
This behavior applies even if the request targets other open indices.
:param expand_wildcards: Type of index that wildcard patterns can match. If the
request can target data streams, this argument determines whether wildcard
expressions match hidden data streams. Supports comma-separated values, such
as `open,hidden`.
:param ignore_unavailable: If `false`, the request returns an error if it targets
a missing or closed index.
"""
__path_parts: t.Dict[str, str]
if index not in SKIP_IN_PATH:
__path_parts = {"index": _quote(index)}
__path = f'/{__path_parts["index"]}/_refresh'
else:
__path_parts = {}
__path = "/_refresh"
__query: t.Dict[str, t.Any] = {}
if allow_no_indices is not None:
__query["allow_no_indices"] = allow_no_indices
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if ignore_unavailable is not None:
__query["ignore_unavailable"] = ignore_unavailable
if pretty is not None:
__query["pretty"] = pretty
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"POST",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.refresh",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def reload_search_analyzers(
self,
*,
index: t.Union[str, t.Sequence[str]],
allow_no_indices: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
ignore_unavailable: t.Optional[bool] = None,
pretty: t.Optional[bool] = None,
resource: t.Optional[str] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Reload search analyzers.
Reload an index's search analyzers and their resources.
For data streams, the API reloads search analyzers and resources for the stream's backing indices.</p>
<p>IMPORTANT: After reloading the search analyzers you should clear the request cache to make sure it doesn't contain responses derived from the previous versions of the analyzer.</p>
<p>You can use the reload search analyzers API to pick up changes to synonym files used in the <code>synonym_graph</code> or <code>synonym</code> token filter of a search analyzer.
To be eligible, the token filter must have an <code>updateable</code> flag of <code>true</code> and only be used in search analyzers.</p>
<p>NOTE: This API does not perform a reload for each shard of an index.
Instead, it performs a reload for each node containing index shards.
As a result, the total shard count returned by the API can differ from the number of index shards.
Because reloading affects every node with an index shard, it is important to update the synonym file on every data node in the cluster--including nodes that don't contain a shard replica--before using this API.
This ensures the synonym file is updated everywhere in the cluster in case shards are relocated in the future.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-reload-search-analyzers>`_
:param index: A comma-separated list of index names to reload analyzers for
:param allow_no_indices: Whether to ignore if a wildcard indices expression resolves
into no concrete indices. (This includes `_all` string or when no indices
have been specified)
:param expand_wildcards: Whether to expand wildcard expression to concrete indices
that are open, closed or both.
:param ignore_unavailable: Whether specified concrete indices should be ignored
when unavailable (missing or closed)
:param resource: Changed resource to reload analyzers from if applicable
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'index'")
__path_parts: t.Dict[str, str] = {"index": _quote(index)}
__path = f'/{__path_parts["index"]}/_reload_search_analyzers'
__query: t.Dict[str, t.Any] = {}
if allow_no_indices is not None:
__query["allow_no_indices"] = allow_no_indices
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if ignore_unavailable is not None:
__query["ignore_unavailable"] = ignore_unavailable
if pretty is not None:
__query["pretty"] = pretty
if resource is not None:
__query["resource"] = resource
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"POST",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.reload_search_analyzers",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def remove_block(
self,
*,
index: str,
block: t.Union[str, t.Literal["metadata", "read", "read_only", "write"]],
allow_no_indices: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
ignore_unavailable: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Remove an index block.</p>
<p>Remove an index block from an index.
Index blocks limit the operations allowed on an index by blocking specific operation types.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-remove-block>`_
:param index: A comma-separated list or wildcard expression of index names used
to limit the request. By default, you must explicitly name the indices you
are removing blocks from. To allow the removal of blocks from indices with
`_all`, `*`, or other wildcard expressions, change the `action.destructive_requires_name`
setting to `false`. You can update this setting in the `elasticsearch.yml`
file or by using the cluster update settings API.
:param block: The block type to remove from the index.
:param allow_no_indices: If `false`, the request returns an error if any wildcard
expression, index alias, or `_all` value targets only missing or closed indices.
This behavior applies even if the request targets other open indices. For
example, a request targeting `foo*,bar*` returns an error if an index starts
with `foo` but no index starts with `bar`.
:param expand_wildcards: The type of index that wildcard patterns can match.
If the request can target data streams, this argument determines whether
wildcard expressions match hidden data streams. It supports comma-separated
values, such as `open,hidden`.
:param ignore_unavailable: If `false`, the request returns an error if it targets
a missing or closed index.
:param master_timeout: The period to wait for the master node. If the master
node is not available before the timeout expires, the request fails and returns
an error. It can also be set to `-1` to indicate that the request should
never timeout.
:param timeout: The period to wait for a response from all relevant nodes in
the cluster after updating the cluster metadata. If no response is received
before the timeout expires, the cluster metadata update still applies but
the response will indicate that it was not completely acknowledged. It can
also be set to `-1` to indicate that the request should never timeout.
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'index'")
if block in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'block'")
__path_parts: t.Dict[str, str] = {
"index": _quote(index),
"block": _quote(block),
}
__path = f'/{__path_parts["index"]}/_block/{__path_parts["block"]}'
__query: t.Dict[str, t.Any] = {}
if allow_no_indices is not None:
__query["allow_no_indices"] = allow_no_indices
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if ignore_unavailable is not None:
__query["ignore_unavailable"] = ignore_unavailable
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
if timeout is not None:
__query["timeout"] = timeout
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"DELETE",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.remove_block",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def resolve_cluster(
self,
*,
name: t.Optional[t.Union[str, t.Sequence[str]]] = None,
allow_no_indices: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
ignore_throttled: t.Optional[bool] = None,
ignore_unavailable: t.Optional[bool] = None,
pretty: t.Optional[bool] = None,
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Resolve the cluster.</p>
<p>Resolve the specified index expressions to return information about each cluster, including the local "querying" cluster, if included.
If no index expression is provided, the API will return information about all the remote clusters that are configured on the querying cluster.</p>
<p>This endpoint is useful before doing a cross-cluster search in order to determine which remote clusters should be included in a search.</p>
<p>You use the same index expression with this endpoint as you would for cross-cluster search.
Index and cluster exclusions are also supported with this endpoint.</p>
<p>For each cluster in the index expression, information is returned about:</p>
<ul>
<li>Whether the querying ("local") cluster is currently connected to each remote cluster specified in the index expression. Note that this endpoint actively attempts to contact the remote clusters, unlike the <code>remote/info</code> endpoint.</li>
<li>Whether each remote cluster is configured with <code>skip_unavailable</code> as <code>true</code> or <code>false</code>.</li>
<li>Whether there are any indices, aliases, or data streams on that cluster that match the index expression.</li>
<li>Whether the search is likely to have errors returned when you do the cross-cluster search (including any authorization errors if you do not have permission to query the index).</li>
<li>Cluster version information, including the Elasticsearch server version.</li>
</ul>
<p>For example, <code>GET /_resolve/cluster/my-index-*,cluster*:my-index-*</code> returns information about the local cluster and all remotely configured clusters that start with the alias <code>cluster*</code>.
Each cluster returns information about whether it has any indices, aliases or data streams that match <code>my-index-*</code>.</p>
<h2>Note on backwards compatibility</h2>
<p>The ability to query without an index expression was added in version 8.18, so when
querying remote clusters older than that, the local cluster will send the index
expression <code>dummy*</code> to those remote clusters. Thus, if an errors occur, you may see a reference
to that index expression even though you didn't request it. If it causes a problem, you can
instead include an index expression like <code>*:*</code> to bypass the issue.</p>
<h2>Advantages of using this endpoint before a cross-cluster search</h2>
<p>You may want to exclude a cluster or index from a search when:</p>
<ul>
<li>A remote cluster is not currently connected and is configured with <code>skip_unavailable=false</code>. Running a cross-cluster search under those conditions will cause the entire search to fail.</li>
<li>A cluster has no matching indices, aliases or data streams for the index expression (or your user does not have permissions to search them). For example, suppose your index expression is <code>logs*,remote1:logs*</code> and the remote1 cluster has no indices, aliases or data streams that match <code>logs*</code>. In that case, that cluster will return no results from that cluster if you include it in a cross-cluster search.</li>
<li>The index expression (combined with any query parameters you specify) will likely cause an exception to be thrown when you do the search. In these cases, the "error" field in the <code>_resolve/cluster</code> response will be present. (This is also where security/permission errors will be shown.)</li>
<li>A remote cluster is an older version that does not support the feature you want to use in your search.</li>
</ul>
<h2>Test availability of remote clusters</h2>
<p>The <code>remote/info</code> endpoint is commonly used to test whether the "local" cluster (the cluster being queried) is connected to its remote clusters, but it does not necessarily reflect whether the remote cluster is available or not.
The remote cluster may be available, while the local cluster is not currently connected to it.</p>
<p>You can use the <code>_resolve/cluster</code> API to attempt to reconnect to remote clusters.
For example with <code>GET _resolve/cluster</code> or <code>GET _resolve/cluster/*:*</code>.
The <code>connected</code> field in the response will indicate whether it was successful.
If a connection was (re-)established, this will also cause the <code>remote/info</code> endpoint to now indicate a connected status.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-resolve-cluster>`_
:param name: A comma-separated list of names or index patterns for the indices,
aliases, and data streams to resolve. Resources on remote clusters can be
specified using the `<cluster>`:`<name>` syntax. Index and cluster exclusions
(e.g., `-cluster1:*`) are also supported. If no index expression is specified,
information about all remote clusters configured on the local cluster is
returned without doing any index matching
:param allow_no_indices: If false, the request returns an error if any wildcard
expression, index alias, or `_all` value targets only missing or closed indices.
This behavior applies even if the request targets other open indices. For
example, a request targeting `foo*,bar*` returns an error if an index starts
with `foo` but no index starts with `bar`. NOTE: This option is only supported
when specifying an index expression. You will get an error if you specify
index options to the `_resolve/cluster` API endpoint that takes no index
expression.
:param expand_wildcards: Type of index that wildcard patterns can match. If the
request can target data streams, this argument determines whether wildcard
expressions match hidden data streams. Supports comma-separated values, such
as `open,hidden`. NOTE: This option is only supported when specifying an
index expression. You will get an error if you specify index options to the
`_resolve/cluster` API endpoint that takes no index expression.
:param ignore_throttled: If true, concrete, expanded, or aliased indices are
ignored when frozen. NOTE: This option is only supported when specifying
an index expression. You will get an error if you specify index options to
the `_resolve/cluster` API endpoint that takes no index expression.
:param ignore_unavailable: If false, the request returns an error if it targets
a missing or closed index. NOTE: This option is only supported when specifying
an index expression. You will get an error if you specify index options to
the `_resolve/cluster` API endpoint that takes no index expression.
:param timeout: The maximum time to wait for remote clusters to respond. If a
remote cluster does not respond within this timeout period, the API response
will show the cluster as not connected and include an error message that
the request timed out. The default timeout is unset and the query can take
as long as the networking layer is configured to wait for remote clusters
that are not responding (typically 30 seconds).
"""
__path_parts: t.Dict[str, str]
if name not in SKIP_IN_PATH:
__path_parts = {"name": _quote(name)}
__path = f'/_resolve/cluster/{__path_parts["name"]}'
else:
__path_parts = {}
__path = "/_resolve/cluster"
__query: t.Dict[str, t.Any] = {}
if allow_no_indices is not None:
__query["allow_no_indices"] = allow_no_indices
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if ignore_throttled is not None:
__query["ignore_throttled"] = ignore_throttled
if ignore_unavailable is not None:
__query["ignore_unavailable"] = ignore_unavailable
if pretty is not None:
__query["pretty"] = pretty
if timeout is not None:
__query["timeout"] = timeout
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"GET",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.resolve_cluster",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def resolve_index(
self,
*,
name: t.Union[str, t.Sequence[str]],
allow_no_indices: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
ignore_unavailable: t.Optional[bool] = None,
pretty: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Resolve indices.
Resolve the names and/or index patterns for indices, aliases, and data streams.
Multiple patterns and remote clusters are supported.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-resolve-index>`_
:param name: Comma-separated name(s) or index pattern(s) of the indices, aliases,
and data streams to resolve. Resources on remote clusters can be specified
using the `<cluster>`:`<name>` syntax.
:param allow_no_indices: If `false`, the request returns an error if any wildcard
expression, index alias, or `_all` value targets only missing or closed indices.
This behavior applies even if the request targets other open indices. For
example, a request targeting `foo*,bar*` returns an error if an index starts
with `foo` but no index starts with `bar`.
:param expand_wildcards: Type of index that wildcard patterns can match. If the
request can target data streams, this argument determines whether wildcard
expressions match hidden data streams. Supports comma-separated values, such
as `open,hidden`.
:param ignore_unavailable: If `false`, the request returns an error if it targets
a missing or closed index.
"""
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'name'")
__path_parts: t.Dict[str, str] = {"name": _quote(name)}
__path = f'/_resolve/index/{__path_parts["name"]}'
__query: t.Dict[str, t.Any] = {}
if allow_no_indices is not None:
__query["allow_no_indices"] = allow_no_indices
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if ignore_unavailable is not None:
__query["ignore_unavailable"] = ignore_unavailable
if pretty is not None:
__query["pretty"] = pretty
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"GET",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.resolve_index",
path_parts=__path_parts,
)
@_rewrite_parameters(
body_fields=("aliases", "conditions", "mappings", "settings"),
)
async def rollover(
self,
*,
alias: str,
new_index: t.Optional[str] = None,
aliases: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
conditions: t.Optional[t.Mapping[str, t.Any]] = None,
dry_run: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
lazy: t.Optional[bool] = None,
mappings: t.Optional[t.Mapping[str, t.Any]] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
settings: t.Optional[t.Mapping[str, t.Any]] = None,
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
wait_for_active_shards: t.Optional[
t.Union[int, t.Union[str, t.Literal["all", "index-setting"]]]
] = None,
body: t.Optional[t.Dict[str, t.Any]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Roll over to a new index.
TIP: It is recommended to use the index lifecycle rollover action to automate rollovers.</p>
<p>The rollover API creates a new index for a data stream or index alias.
The API behavior depends on the rollover target.</p>
<p><strong>Roll over a data stream</strong></p>
<p>If you roll over a data stream, the API creates a new write index for the stream.
The stream's previous write index becomes a regular backing index.
A rollover also increments the data stream's generation.</p>
<p><strong>Roll over an index alias with a write index</strong></p>
<p>TIP: Prior to Elasticsearch 7.9, you'd typically use an index alias with a write index to manage time series data.
Data streams replace this functionality, require less maintenance, and automatically integrate with data tiers.</p>
<p>If an index alias points to multiple indices, one of the indices must be a write index.
The rollover API creates a new write index for the alias with <code>is_write_index</code> set to <code>true</code>.
The API also <code>sets is_write_index</code> to <code>false</code> for the previous write index.</p>
<p><strong>Roll over an index alias with one index</strong></p>
<p>If you roll over an index alias that points to only one index, the API creates a new index for the alias and removes the original index from the alias.</p>
<p>NOTE: A rollover creates a new index and is subject to the <code>wait_for_active_shards</code> setting.</p>
<p><strong>Increment index names for an alias</strong></p>
<p>When you roll over an index alias, you can specify a name for the new index.
If you don't specify a name and the current index ends with <code>-</code> and a number, such as <code>my-index-000001</code> or <code>my-index-3</code>, the new index name increments that number.
For example, if you roll over an alias with a current index of <code>my-index-000001</code>, the rollover creates a new index named <code>my-index-000002</code>.
This number is always six characters and zero-padded, regardless of the previous index's name.</p>
<p>If you use an index alias for time series data, you can use date math in the index name to track the rollover date.
For example, you can create an alias that points to an index named <code><my-index-{now/d}-000001></code>.
If you create the index on May 6, 2099, the index's name is <code>my-index-2099.05.06-000001</code>.
If you roll over the alias on May 7, 2099, the new index's name is <code>my-index-2099.05.07-000002</code>.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-rollover>`_
:param alias: Name of the data stream or index alias to roll over.
:param new_index: Name of the index to create. Supports date math. Data streams
do not support this parameter.
:param aliases: Aliases for the target index. Data streams do not support this
parameter.
:param conditions: Conditions for the rollover. If specified, Elasticsearch only
performs the rollover if the current index satisfies these conditions. If
this parameter is not specified, Elasticsearch performs the rollover unconditionally.
If conditions are specified, at least one of them must be a `max_*` condition.
The index will rollover if any `max_*` condition is satisfied and all `min_*`
conditions are satisfied.
:param dry_run: If `true`, checks whether the current index satisfies the specified
conditions but does not perform a rollover.
:param lazy: If set to true, the rollover action will only mark a data stream
to signal that it needs to be rolled over at the next write. Only allowed
on data streams.
:param mappings: Mapping for fields in the index. If specified, this mapping
can include field names, field data types, and mapping paramaters.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
:param settings: Configuration options for the index. Data streams do not support
this parameter.
:param timeout: Period to wait for a response. If no response is received before
the timeout expires, the request fails and returns an error.
:param wait_for_active_shards: The number of shard copies that must be active
before proceeding with the operation. Set to all or any positive integer
up to the total number of shards in the index (`number_of_replicas+1`).
"""
if alias in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'alias'")
__path_parts: t.Dict[str, str]
if alias not in SKIP_IN_PATH and new_index not in SKIP_IN_PATH:
__path_parts = {"alias": _quote(alias), "new_index": _quote(new_index)}
__path = f'/{__path_parts["alias"]}/_rollover/{__path_parts["new_index"]}'
elif alias not in SKIP_IN_PATH:
__path_parts = {"alias": _quote(alias)}
__path = f'/{__path_parts["alias"]}/_rollover'
else:
raise ValueError("Couldn't find a path for the given parameters")
__query: t.Dict[str, t.Any] = {}
__body: t.Dict[str, t.Any] = body if body is not None else {}
if dry_run is not None:
__query["dry_run"] = dry_run
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if lazy is not None:
__query["lazy"] = lazy
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
if timeout is not None:
__query["timeout"] = timeout
if wait_for_active_shards is not None:
__query["wait_for_active_shards"] = wait_for_active_shards
if not __body:
if aliases is not None:
__body["aliases"] = aliases
if conditions is not None:
__body["conditions"] = conditions
if mappings is not None:
__body["mappings"] = mappings
if settings is not None:
__body["settings"] = settings
if not __body:
__body = None # type: ignore[assignment]
__headers = {"accept": "application/json"}
if __body is not None:
__headers["content-type"] = "application/json"
return await self.perform_request( # type: ignore[return-value]
"POST",
__path,
params=__query,
headers=__headers,
body=__body,
endpoint_id="indices.rollover",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def segments(
self,
*,
index: t.Optional[t.Union[str, t.Sequence[str]]] = None,
allow_no_indices: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
ignore_unavailable: t.Optional[bool] = None,
pretty: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Get index segments.
Get low-level information about the Lucene segments in index shards.
For data streams, the API returns information about the stream's backing indices.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-segments>`_
:param index: Comma-separated list of data streams, indices, and aliases used
to limit the request. Supports wildcards (`*`). To target all data streams
and indices, omit this parameter or use `*` or `_all`.
:param allow_no_indices: If `false`, the request returns an error if any wildcard
expression, index alias, or `_all` value targets only missing or closed indices.
This behavior applies even if the request targets other open indices.
:param expand_wildcards: Type of index that wildcard patterns can match. If the
request can target data streams, this argument determines whether wildcard
expressions match hidden data streams. Supports comma-separated values, such
as `open,hidden`.
:param ignore_unavailable: If `false`, the request returns an error if it targets
a missing or closed index.
"""
__path_parts: t.Dict[str, str]
if index not in SKIP_IN_PATH:
__path_parts = {"index": _quote(index)}
__path = f'/{__path_parts["index"]}/_segments'
else:
__path_parts = {}
__path = "/_segments"
__query: t.Dict[str, t.Any] = {}
if allow_no_indices is not None:
__query["allow_no_indices"] = allow_no_indices
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if ignore_unavailable is not None:
__query["ignore_unavailable"] = ignore_unavailable
if pretty is not None:
__query["pretty"] = pretty
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"GET",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.segments",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def shard_stores(
self,
*,
index: t.Optional[t.Union[str, t.Sequence[str]]] = None,
allow_no_indices: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
ignore_unavailable: t.Optional[bool] = None,
pretty: t.Optional[bool] = None,
status: t.Optional[
t.Union[
t.Sequence[t.Union[str, t.Literal["all", "green", "red", "yellow"]]],
t.Union[str, t.Literal["all", "green", "red", "yellow"]],
]
] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Get index shard stores.
Get store information about replica shards in one or more indices.
For data streams, the API retrieves store information for the stream's backing indices.</p>
<p>The index shard stores API returns the following information:</p>
<ul>
<li>The node on which each replica shard exists.</li>
<li>The allocation ID for each replica shard.</li>
<li>A unique ID for each replica shard.</li>
<li>Any errors encountered while opening the shard index or from an earlier failure.</li>
</ul>
<p>By default, the API returns store information only for primary shards that are unassigned or have one or more unassigned replica shards.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-shard-stores>`_
:param index: List of data streams, indices, and aliases used to limit the request.
:param allow_no_indices: If false, the request returns an error if any wildcard
expression, index alias, or _all value targets only missing or closed indices.
This behavior applies even if the request targets other open indices.
:param expand_wildcards: Type of index that wildcard patterns can match. If the
request can target data streams, this argument determines whether wildcard
expressions match hidden data streams.
:param ignore_unavailable: If true, missing or closed indices are not included
in the response.
:param status: List of shard health statuses used to limit the request.
"""
__path_parts: t.Dict[str, str]
if index not in SKIP_IN_PATH:
__path_parts = {"index": _quote(index)}
__path = f'/{__path_parts["index"]}/_shard_stores'
else:
__path_parts = {}
__path = "/_shard_stores"
__query: t.Dict[str, t.Any] = {}
if allow_no_indices is not None:
__query["allow_no_indices"] = allow_no_indices
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if ignore_unavailable is not None:
__query["ignore_unavailable"] = ignore_unavailable
if pretty is not None:
__query["pretty"] = pretty
if status is not None:
__query["status"] = status
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"GET",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.shard_stores",
path_parts=__path_parts,
)
@_rewrite_parameters(
body_fields=("aliases", "settings"),
)
async def shrink(
self,
*,
index: str,
target: str,
aliases: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
settings: t.Optional[t.Mapping[str, t.Any]] = None,
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
wait_for_active_shards: t.Optional[
t.Union[int, t.Union[str, t.Literal["all", "index-setting"]]]
] = None,
body: t.Optional[t.Dict[str, t.Any]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Shrink an index.
Shrink an index into a new index with fewer primary shards.</p>
<p>Before you can shrink an index:</p>
<ul>
<li>The index must be read-only.</li>
<li>A copy of every shard in the index must reside on the same node.</li>
<li>The index must have a green health status.</li>
</ul>
<p>To make shard allocation easier, we recommend you also remove the index's replica shards.
You can later re-add replica shards as part of the shrink operation.</p>
<p>The requested number of primary shards in the target index must be a factor of the number of shards in the source index.
For example an index with 8 primary shards can be shrunk into 4, 2 or 1 primary shards or an index with 15 primary shards can be shrunk into 5, 3 or 1.
If the number of shards in the index is a prime number it can only be shrunk into a single primary shard
Before shrinking, a (primary or replica) copy of every shard in the index must be present on the same node.</p>
<p>The current write index on a data stream cannot be shrunk. In order to shrink the current write index, the data stream must first be rolled over so that a new write index is created and then the previous write index can be shrunk.</p>
<p>A shrink operation:</p>
<ul>
<li>Creates a new target index with the same definition as the source index, but with a smaller number of primary shards.</li>
<li>Hard-links segments from the source index into the target index. If the file system does not support hard-linking, then all segments are copied into the new index, which is a much more time consuming process. Also if using multiple data paths, shards on different data paths require a full copy of segment files if they are not on the same disk since hardlinks do not work across disks.</li>
<li>Recovers the target index as though it were a closed index which had just been re-opened. Recovers shards to the <code>.routing.allocation.initial_recovery._id</code> index setting.</li>
</ul>
<p>IMPORTANT: Indices can only be shrunk if they satisfy the following requirements:</p>
<ul>
<li>The target index must not exist.</li>
<li>The source index must have more primary shards than the target index.</li>
<li>The number of primary shards in the target index must be a factor of the number of primary shards in the source index. The source index must have more primary shards than the target index.</li>
<li>The index must not contain more than 2,147,483,519 documents in total across all shards that will be shrunk into a single shard on the target index as this is the maximum number of docs that can fit into a single shard.</li>
<li>The node handling the shrink process must have sufficient free disk space to accommodate a second copy of the existing index.</li>
</ul>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-shrink>`_
:param index: Name of the source index to shrink.
:param target: Name of the target index to create.
:param aliases: The key is the alias name. Index alias names support date math.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
:param settings: Configuration options for the target index.
:param timeout: Period to wait for a response. If no response is received before
the timeout expires, the request fails and returns an error.
:param wait_for_active_shards: The number of shard copies that must be active
before proceeding with the operation. Set to `all` or any positive integer
up to the total number of shards in the index (`number_of_replicas+1`).
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'index'")
if target in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'target'")
__path_parts: t.Dict[str, str] = {
"index": _quote(index),
"target": _quote(target),
}
__path = f'/{__path_parts["index"]}/_shrink/{__path_parts["target"]}'
__query: t.Dict[str, t.Any] = {}
__body: t.Dict[str, t.Any] = body if body is not None else {}
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
if timeout is not None:
__query["timeout"] = timeout
if wait_for_active_shards is not None:
__query["wait_for_active_shards"] = wait_for_active_shards
if not __body:
if aliases is not None:
__body["aliases"] = aliases
if settings is not None:
__body["settings"] = settings
if not __body:
__body = None # type: ignore[assignment]
__headers = {"accept": "application/json"}
if __body is not None:
__headers["content-type"] = "application/json"
return await self.perform_request( # type: ignore[return-value]
"PUT",
__path,
params=__query,
headers=__headers,
body=__body,
endpoint_id="indices.shrink",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def simulate_index_template(
self,
*,
name: str,
cause: t.Optional[str] = None,
create: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
include_defaults: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Simulate an index.
Get the index configuration that would be applied to the specified index from an existing index template.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-simulate-index-template>`_
:param name: Name of the index to simulate
:param cause: User defined reason for dry-run creating the new template for simulation
purposes
:param create: Whether the index template we optionally defined in the body should
only be dry-run added if new or can also replace an existing one
:param include_defaults: If true, returns all relevant default configurations
for the index template.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
"""
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'name'")
__path_parts: t.Dict[str, str] = {"name": _quote(name)}
__path = f'/_index_template/_simulate_index/{__path_parts["name"]}'
__query: t.Dict[str, t.Any] = {}
if cause is not None:
__query["cause"] = cause
if create is not None:
__query["create"] = create
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if include_defaults is not None:
__query["include_defaults"] = include_defaults
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"POST",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.simulate_index_template",
path_parts=__path_parts,
)
@_rewrite_parameters(
body_fields=(
"allow_auto_create",
"composed_of",
"data_stream",
"deprecated",
"ignore_missing_component_templates",
"index_patterns",
"meta",
"priority",
"template",
"version",
),
parameter_aliases={"_meta": "meta"},
)
async def simulate_template(
self,
*,
name: t.Optional[str] = None,
allow_auto_create: t.Optional[bool] = None,
cause: t.Optional[str] = None,
composed_of: t.Optional[t.Sequence[str]] = None,
create: t.Optional[bool] = None,
data_stream: t.Optional[t.Mapping[str, t.Any]] = None,
deprecated: t.Optional[bool] = None,
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
ignore_missing_component_templates: t.Optional[t.Sequence[str]] = None,
include_defaults: t.Optional[bool] = None,
index_patterns: t.Optional[t.Union[str, t.Sequence[str]]] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
meta: t.Optional[t.Mapping[str, t.Any]] = None,
pretty: t.Optional[bool] = None,
priority: t.Optional[int] = None,
template: t.Optional[t.Mapping[str, t.Any]] = None,
version: t.Optional[int] = None,
body: t.Optional[t.Dict[str, t.Any]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Simulate an index template.
Get the index configuration that would be applied by a particular index template.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-simulate-template>`_
:param name: Name of the index template to simulate. To test a template configuration
before you add it to the cluster, omit this parameter and specify the template
configuration in the request body.
:param allow_auto_create: This setting overrides the value of the `action.auto_create_index`
cluster setting. If set to `true` in a template, then indices can be automatically
created using that template even if auto-creation of indices is disabled
via `actions.auto_create_index`. If set to `false`, then indices or data
streams matching the template must always be explicitly created, and may
never be automatically created.
:param cause: User defined reason for dry-run creating the new template for simulation
purposes
:param composed_of: An ordered list of component template names. Component templates
are merged in the order specified, meaning that the last component template
specified has the highest precedence.
:param create: If true, the template passed in the body is only used if no existing
templates match the same index patterns. If false, the simulation uses the
template with the highest priority. Note that the template is not permanently
added or updated in either case; it is only used for the simulation.
:param data_stream: If this object is included, the template is used to create
data streams and their backing indices. Supports an empty object. Data streams
require a matching index template with a `data_stream` object.
:param deprecated: Marks this index template as deprecated. When creating or
updating a non-deprecated index template that uses deprecated components,
Elasticsearch will emit a deprecation warning.
:param ignore_missing_component_templates: The configuration option ignore_missing_component_templates
can be used when an index template references a component template that might
not exist
:param include_defaults: If true, returns all relevant default configurations
for the index template.
:param index_patterns: Array of wildcard (`*`) expressions used to match the
names of data streams and indices during creation.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
:param meta: Optional user metadata about the index template. May have any contents.
This map is not automatically generated by Elasticsearch.
:param priority: Priority to determine index template precedence when a new data
stream or index is created. The index template with the highest priority
is chosen. If no priority is specified the template is treated as though
it is of priority 0 (lowest priority). This number is not automatically generated
by Elasticsearch.
:param template: Template to be applied. It may optionally include an `aliases`,
`mappings`, or `settings` configuration.
:param version: Version number used to manage index templates externally. This
number is not automatically generated by Elasticsearch.
"""
__path_parts: t.Dict[str, str]
if name not in SKIP_IN_PATH:
__path_parts = {"name": _quote(name)}
__path = f'/_index_template/_simulate/{__path_parts["name"]}'
else:
__path_parts = {}
__path = "/_index_template/_simulate"
__query: t.Dict[str, t.Any] = {}
__body: t.Dict[str, t.Any] = body if body is not None else {}
if cause is not None:
__query["cause"] = cause
if create is not None:
__query["create"] = create
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if include_defaults is not None:
__query["include_defaults"] = include_defaults
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
if not __body:
if allow_auto_create is not None:
__body["allow_auto_create"] = allow_auto_create
if composed_of is not None:
__body["composed_of"] = composed_of
if data_stream is not None:
__body["data_stream"] = data_stream
if deprecated is not None:
__body["deprecated"] = deprecated
if ignore_missing_component_templates is not None:
__body["ignore_missing_component_templates"] = (
ignore_missing_component_templates
)
if index_patterns is not None:
__body["index_patterns"] = index_patterns
if meta is not None:
__body["_meta"] = meta
if priority is not None:
__body["priority"] = priority
if template is not None:
__body["template"] = template
if version is not None:
__body["version"] = version
if not __body:
__body = None # type: ignore[assignment]
__headers = {"accept": "application/json"}
if __body is not None:
__headers["content-type"] = "application/json"
return await self.perform_request( # type: ignore[return-value]
"POST",
__path,
params=__query,
headers=__headers,
body=__body,
endpoint_id="indices.simulate_template",
path_parts=__path_parts,
)
@_rewrite_parameters(
body_fields=("aliases", "settings"),
)
async def split(
self,
*,
index: str,
target: str,
aliases: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
settings: t.Optional[t.Mapping[str, t.Any]] = None,
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
wait_for_active_shards: t.Optional[
t.Union[int, t.Union[str, t.Literal["all", "index-setting"]]]
] = None,
body: t.Optional[t.Dict[str, t.Any]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Split an index.
Split an index into a new index with more primary shards.</p>
<ul>
<li>
<p>Before you can split an index:</p>
</li>
<li>
<p>The index must be read-only.</p>
</li>
<li>
<p>The cluster health status must be green.</p>
</li>
</ul>
<p>You can do make an index read-only with the following request using the add index block API:</p>
<pre><code>PUT /my_source_index/_block/write
</code></pre>
<p>The current write index on a data stream cannot be split.
In order to split the current write index, the data stream must first be rolled over so that a new write index is created and then the previous write index can be split.</p>
<p>The number of times the index can be split (and the number of shards that each original shard can be split into) is determined by the <code>index.number_of_routing_shards</code> setting.
The number of routing shards specifies the hashing space that is used internally to distribute documents across shards with consistent hashing.
For instance, a 5 shard index with <code>number_of_routing_shards</code> set to 30 (5 x 2 x 3) could be split by a factor of 2 or 3.</p>
<p>A split operation:</p>
<ul>
<li>Creates a new target index with the same definition as the source index, but with a larger number of primary shards.</li>
<li>Hard-links segments from the source index into the target index. If the file system doesn't support hard-linking, all segments are copied into the new index, which is a much more time consuming process.</li>
<li>Hashes all documents again, after low level files are created, to delete documents that belong to a different shard.</li>
<li>Recovers the target index as though it were a closed index which had just been re-opened.</li>
</ul>
<p>IMPORTANT: Indices can only be split if they satisfy the following requirements:</p>
<ul>
<li>The target index must not exist.</li>
<li>The source index must have fewer primary shards than the target index.</li>
<li>The number of primary shards in the target index must be a multiple of the number of primary shards in the source index.</li>
<li>The node handling the split process must have sufficient free disk space to accommodate a second copy of the existing index.</li>
</ul>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-split>`_
:param index: Name of the source index to split.
:param target: Name of the target index to create.
:param aliases: Aliases for the resulting index.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
:param settings: Configuration options for the target index.
:param timeout: Period to wait for a response. If no response is received before
the timeout expires, the request fails and returns an error.
:param wait_for_active_shards: The number of shard copies that must be active
before proceeding with the operation. Set to `all` or any positive integer
up to the total number of shards in the index (`number_of_replicas+1`).
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'index'")
if target in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'target'")
__path_parts: t.Dict[str, str] = {
"index": _quote(index),
"target": _quote(target),
}
__path = f'/{__path_parts["index"]}/_split/{__path_parts["target"]}'
__query: t.Dict[str, t.Any] = {}
__body: t.Dict[str, t.Any] = body if body is not None else {}
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
if timeout is not None:
__query["timeout"] = timeout
if wait_for_active_shards is not None:
__query["wait_for_active_shards"] = wait_for_active_shards
if not __body:
if aliases is not None:
__body["aliases"] = aliases
if settings is not None:
__body["settings"] = settings
if not __body:
__body = None # type: ignore[assignment]
__headers = {"accept": "application/json"}
if __body is not None:
__headers["content-type"] = "application/json"
return await self.perform_request( # type: ignore[return-value]
"PUT",
__path,
params=__query,
headers=__headers,
body=__body,
endpoint_id="indices.split",
path_parts=__path_parts,
)
@_rewrite_parameters()
async def stats(
self,
*,
index: t.Optional[t.Union[str, t.Sequence[str]]] = None,
metric: t.Optional[t.Union[str, t.Sequence[str]]] = None,
completion_fields: t.Optional[t.Union[str, t.Sequence[str]]] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
fielddata_fields: t.Optional[t.Union[str, t.Sequence[str]]] = None,
fields: t.Optional[t.Union[str, t.Sequence[str]]] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
forbid_closed_indices: t.Optional[bool] = None,
groups: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
include_segment_file_sizes: t.Optional[bool] = None,
include_unloaded_segments: t.Optional[bool] = None,
level: t.Optional[
t.Union[str, t.Literal["cluster", "indices", "shards"]]
] = None,
pretty: t.Optional[bool] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Get index statistics.
For data streams, the API retrieves statistics for the stream's backing indices.</p>
<p>By default, the returned statistics are index-level with <code>primaries</code> and <code>total</code> aggregations.
<code>primaries</code> are the values for only the primary shards.
<code>total</code> are the accumulated values for both primary and replica shards.</p>
<p>To get shard-level statistics, set the <code>level</code> parameter to <code>shards</code>.</p>
<p>NOTE: When moving to another node, the shard-level statistics for a shard are cleared.
Although the shard is no longer part of the node, that node retains any node-level statistics to which the shard contributed.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-stats>`_
:param index: A comma-separated list of index names; use `_all` or empty string
to perform the operation on all indices
:param metric: Limit the information returned the specific metrics.
:param completion_fields: Comma-separated list or wildcard expressions of fields
to include in fielddata and suggest statistics.
:param expand_wildcards: Type of index that wildcard patterns can match. If the
request can target data streams, this argument determines whether wildcard
expressions match hidden data streams. Supports comma-separated values, such
as `open,hidden`.
:param fielddata_fields: Comma-separated list or wildcard expressions of fields
to include in fielddata statistics.
:param fields: Comma-separated list or wildcard expressions of fields to include
in the statistics.
:param forbid_closed_indices: If true, statistics are not collected from closed
indices.
:param groups: Comma-separated list of search groups to include in the search
statistics.
:param include_segment_file_sizes: If true, the call reports the aggregated disk
usage of each one of the Lucene index files (only applies if segment stats
are requested).
:param include_unloaded_segments: If true, the response includes information
from segments that are not loaded into memory.
:param level: Indicates whether statistics are aggregated at the cluster, index,
or shard level.
"""
__path_parts: t.Dict[str, str]
if index not in SKIP_IN_PATH and metric not in SKIP_IN_PATH:
__path_parts = {"index": _quote(index), "metric": _quote(metric)}
__path = f'/{__path_parts["index"]}/_stats/{__path_parts["metric"]}'
elif index not in SKIP_IN_PATH:
__path_parts = {"index": _quote(index)}
__path = f'/{__path_parts["index"]}/_stats'
elif metric not in SKIP_IN_PATH:
__path_parts = {"metric": _quote(metric)}
__path = f'/_stats/{__path_parts["metric"]}'
else:
__path_parts = {}
__path = "/_stats"
__query: t.Dict[str, t.Any] = {}
if completion_fields is not None:
__query["completion_fields"] = completion_fields
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if fielddata_fields is not None:
__query["fielddata_fields"] = fielddata_fields
if fields is not None:
__query["fields"] = fields
if filter_path is not None:
__query["filter_path"] = filter_path
if forbid_closed_indices is not None:
__query["forbid_closed_indices"] = forbid_closed_indices
if groups is not None:
__query["groups"] = groups
if human is not None:
__query["human"] = human
if include_segment_file_sizes is not None:
__query["include_segment_file_sizes"] = include_segment_file_sizes
if include_unloaded_segments is not None:
__query["include_unloaded_segments"] = include_unloaded_segments
if level is not None:
__query["level"] = level
if pretty is not None:
__query["pretty"] = pretty
__headers = {"accept": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"GET",
__path,
params=__query,
headers=__headers,
endpoint_id="indices.stats",
path_parts=__path_parts,
)
@_rewrite_parameters(
body_fields=("actions",),
)
async def update_aliases(
self,
*,
actions: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
pretty: t.Optional[bool] = None,
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
body: t.Optional[t.Dict[str, t.Any]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Create or update an alias.
Adds a data stream or index to an alias.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-update-aliases>`_
:param actions: Actions to perform.
:param master_timeout: Period to wait for a connection to the master node. If
no response is received before the timeout expires, the request fails and
returns an error.
:param timeout: Period to wait for a response. If no response is received before
the timeout expires, the request fails and returns an error.
"""
__path_parts: t.Dict[str, str] = {}
__path = "/_aliases"
__query: t.Dict[str, t.Any] = {}
__body: t.Dict[str, t.Any] = body if body is not None else {}
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if master_timeout is not None:
__query["master_timeout"] = master_timeout
if pretty is not None:
__query["pretty"] = pretty
if timeout is not None:
__query["timeout"] = timeout
if not __body:
if actions is not None:
__body["actions"] = actions
__headers = {"accept": "application/json", "content-type": "application/json"}
return await self.perform_request( # type: ignore[return-value]
"POST",
__path,
params=__query,
headers=__headers,
body=__body,
endpoint_id="indices.update_aliases",
path_parts=__path_parts,
)
@_rewrite_parameters(
body_fields=("query",),
)
async def validate_query(
self,
*,
index: t.Optional[t.Union[str, t.Sequence[str]]] = None,
all_shards: t.Optional[bool] = None,
allow_no_indices: t.Optional[bool] = None,
analyze_wildcard: t.Optional[bool] = None,
analyzer: t.Optional[str] = None,
default_operator: t.Optional[t.Union[str, t.Literal["and", "or"]]] = None,
df: t.Optional[str] = None,
error_trace: t.Optional[bool] = None,
expand_wildcards: t.Optional[
t.Union[
t.Sequence[
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]]
],
t.Union[str, t.Literal["all", "closed", "hidden", "none", "open"]],
]
] = None,
explain: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
ignore_unavailable: t.Optional[bool] = None,
lenient: t.Optional[bool] = None,
pretty: t.Optional[bool] = None,
q: t.Optional[str] = None,
query: t.Optional[t.Mapping[str, t.Any]] = None,
rewrite: t.Optional[bool] = None,
body: t.Optional[t.Dict[str, t.Any]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html
<p>Validate a query.
Validates a query without running it.</p>
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-validate-query>`_
:param index: Comma-separated list of data streams, indices, and aliases to search.
Supports wildcards (`*`). To search all data streams or indices, omit this
parameter or use `*` or `_all`.
:param all_shards: If `true`, the validation is executed on all shards instead
of one random shard per index.
:param allow_no_indices: If `false`, the request returns an error if any wildcard
expression, index alias, or `_all` value targets only missing or closed indices.
This behavior applies even if the request targets other open indices.
:param analyze_wildcard: If `true`, wildcard and prefix queries are analyzed.
:param analyzer: Analyzer to use for the query string. This parameter can only
be used when the `q` query string parameter is specified.
:param default_operator: The default operator for query string query: `AND` or
`OR`.
:param df: Field to use as default where no field prefix is given in the query
string. This parameter can only be used when the `q` query string parameter
is specified.
:param expand_wildcards: Type of index that wildcard patterns can match. If the
request can target data streams, this argument determines whether wildcard
expressions match hidden data streams. Supports comma-separated values, such
as `open,hidden`.
:param explain: If `true`, the response returns detailed information if an error
has occurred.
:param ignore_unavailable: If `false`, the request returns an error if it targets
a missing or closed index.
:param lenient: If `true`, format-based query failures (such as providing text
to a numeric field) in the query string will be ignored.
:param q: Query in the Lucene query string syntax.
:param query: Query in the Lucene query string syntax.
:param rewrite: If `true`, returns a more detailed explanation showing the actual
Lucene query that will be executed.
"""
__path_parts: t.Dict[str, str]
if index not in SKIP_IN_PATH:
__path_parts = {"index": _quote(index)}
__path = f'/{__path_parts["index"]}/_validate/query'
else:
__path_parts = {}
__path = "/_validate/query"
__query: t.Dict[str, t.Any] = {}
__body: t.Dict[str, t.Any] = body if body is not None else {}
if all_shards is not None:
__query["all_shards"] = all_shards
if allow_no_indices is not None:
__query["allow_no_indices"] = allow_no_indices
if analyze_wildcard is not None:
__query["analyze_wildcard"] = analyze_wildcard
if analyzer is not None:
__query["analyzer"] = analyzer
if default_operator is not None:
__query["default_operator"] = default_operator
if df is not None:
__query["df"] = df
if error_trace is not None:
__query["error_trace"] = error_trace
if expand_wildcards is not None:
__query["expand_wildcards"] = expand_wildcards
if explain is not None:
__query["explain"] = explain
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if ignore_unavailable is not None:
__query["ignore_unavailable"] = ignore_unavailable
if lenient is not None:
__query["lenient"] = lenient
if pretty is not None:
__query["pretty"] = pretty
if q is not None:
__query["q"] = q
if rewrite is not None:
__query["rewrite"] = rewrite
if not __body:
if query is not None:
__body["query"] = query
if not __body:
__body = None # type: ignore[assignment]
__headers = {"accept": "application/json"}
if __body is not None:
__headers["content-type"] = "application/json"
return await self.perform_request( # type: ignore[return-value]
"POST",
__path,
params=__query,
headers=__headers,
body=__body,
endpoint_id="indices.validate_query",
path_parts=__path_parts,
)
|