Skip to content

Commit abeb561

Browse files
authored
Merge pull request #3473 from meilisearch/create-code-samples
Add code samples instead of raw examples with curl only
2 parents 19228f9 + 4c9f323 commit abeb561

51 files changed

Lines changed: 878 additions & 488 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.code-samples.meilisearch.yaml

Lines changed: 337 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,15 @@ update_localized_attribute_settings_1: |-
544544
--data-binary '[
545545
{"locales": ["jpn"], "attributePatterns": ["*_ja"]}
546546
]'
547+
multilingual_dataset_guide_update_localized_attributes_1: |-
548+
curl \
549+
-X PUT 'MEILISEARCH_URL/indexes/INDEX_NAME/settings/localized-attributes' \
550+
-H 'Content-Type: application/json' \
551+
--data-binary '[
552+
{ "attributePatterns": ["*_en"], "locales": ["eng"] },
553+
{ "attributePatterns": ["*_de"], "locales": ["deu"] },
554+
{ "attributePatterns": ["*_fr"], "locales": ["fra"] }
555+
]'
547556
# delete_indexes_indexUid_settings_localized_attributes
548557
reset_localized_attribute_settings_1: |-
549558
curl \
@@ -1041,7 +1050,6 @@ phrase_search_1: |-
10411050
-H 'Content-Type: application/json' \
10421051
--data-binary '{ "q": "\"african american\" horror" }'
10431052
authorization_header_1: |-
1044-
# replace the MASTER_KEY placeholder with your master key
10451053
curl \
10461054
-X GET 'MEILISEARCH_URL/keys' \
10471055
-H 'Authorization: Bearer MASTER_KEY'
@@ -1138,9 +1146,6 @@ geosearch_guide_sort_usage_2: |-
11381146
"rating:desc"
11391147
]
11401148
}'
1141-
basic_security_tutorial_listing_1: |-
1142-
curl -X GET 'MEILISEARCH_URL/keys' \
1143-
-H 'Authorization: Bearer MASTER_KEY'
11441149
basic_security_tutorial_admin_1: |-
11451150
curl \
11461151
-X POST 'MEILISEARCH_URL/indexes' \
@@ -1259,8 +1264,8 @@ search_parameter_guide_matching_strategy_3: |-
12591264
}'
12601265
date_guide_index_1: |-
12611266
curl \
1262-
-x POST 'MEILISEARCH_URL/indexes/games/documents' \
1263-
-h 'content-type: application/json' \
1267+
-X POST 'MEILISEARCH_URL/indexes/games/documents' \
1268+
-H 'Content-Type: application/json' \
12641269
--data-binary @games.json
12651270
date_guide_filterable_attributes_1: |-
12661271
curl \
@@ -1510,7 +1515,7 @@ search_parameter_reference_locales_1: |-
15101515
}'
15111516
search_parameter_guide_hybrid_1: |-
15121517
curl -X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \
1513-
-H 'content-type: application/json' \
1518+
-H 'Content-Type: application/json' \
15141519
--data-binary '{
15151520
"q": "kitchen utensils",
15161521
"hybrid": {
@@ -1520,7 +1525,7 @@ search_parameter_guide_hybrid_1: |-
15201525
}'
15211526
search_parameter_guide_vector_1: |-
15221527
curl -X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \
1523-
-H 'content-type: application/json' \
1528+
-H 'Content-Type: application/json' \
15241529
--data-binary '{
15251530
"vector": [0, 1, 2],
15261531
"hybrid": {
@@ -1529,7 +1534,7 @@ search_parameter_guide_vector_1: |-
15291534
}'
15301535
search_parameter_reference_retrieve_vectors_1: |-
15311536
curl -X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \
1532-
-H 'content-type: application/json' \
1537+
-H 'Content-Type: application/json' \
15331538
--data-binary '{
15341539
"q": "kitchen utensils",
15351540
"retrieveVectors": true,
@@ -1570,3 +1575,326 @@ list_index_fields_1: |-
15701575
curl \
15711576
-X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/fields' \
15721577
-H 'Content-Type: application/json'
1578+
update_experimental_features_chat_1: |-
1579+
curl \
1580+
-X PATCH 'MEILISEARCH_URL/experimental-features/' \
1581+
-H 'Content-Type: application/json' \
1582+
--data-binary '{
1583+
"chatCompletions": true
1584+
}'
1585+
update_experimental_features_contains_1: |-
1586+
curl \
1587+
-X PATCH 'MEILISEARCH_URL/experimental-features/' \
1588+
-H 'Content-Type: application/json' \
1589+
--data-binary '{
1590+
"containsFilter": true
1591+
}'
1592+
update_experimental_features_multimodal_1: |-
1593+
curl \
1594+
-X PATCH 'MEILISEARCH_URL/experimental-features/' \
1595+
-H 'Content-Type: application/json' \
1596+
--data-binary '{
1597+
"multimodal": true
1598+
}'
1599+
ai_search_user_embeddings_documents_1: |-
1600+
curl \
1601+
-X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/documents' \
1602+
-H 'Content-Type: application/json' \
1603+
--data-binary '[
1604+
{ "id": 0, "_vectors": { "EMBEDDER_NAME": [0, 0.8, -0.2]}, "text": "frying pan" },
1605+
{ "id": 1, "_vectors": { "EMBEDDER_NAME": [1, -0.2, 0]}, "text": "baking dish" }
1606+
]'
1607+
ai_search_user_embeddings_search_vector_filter_1: |-
1608+
curl \
1609+
-X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \
1610+
-H 'Content-Type: application/json' \
1611+
--data-binary '{
1612+
"vector": [0, 1, 2],
1613+
"filter": "price < 10",
1614+
"sort": ["price:asc"],
1615+
"hybrid": {
1616+
"embedder": "EMBEDDER_NAME"
1617+
}
1618+
}'
1619+
user_provided_embeddings_settings_1: |-
1620+
curl \
1621+
-X PATCH 'MEILISEARCH_URL/indexes/INDEX_NAME/settings' \
1622+
-H 'Content-Type: application/json' \
1623+
--data-binary '{
1624+
"embedders": {
1625+
"EMBEDDER_NAME": {
1626+
"source": "userProvided",
1627+
"dimensions": MODEL_DIMENSIONS
1628+
}
1629+
}
1630+
}'
1631+
image_search_user_embeddings_search_1: |-
1632+
curl \
1633+
-X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \
1634+
-H 'Content-Type: application/json' \
1635+
--data-binary '{
1636+
"vector": VECTORIZED_QUERY,
1637+
"hybrid": { "embedder": "EMBEDDER_NAME" }
1638+
}'
1639+
image_search_user_embeddings_search_q_1: |-
1640+
curl \
1641+
-X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \
1642+
-H 'Content-Type: application/json' \
1643+
--data-binary '{
1644+
"vector": VECTORIZED_QUERY,
1645+
"hybrid": { "embedder": "EMBEDDER_NAME" },
1646+
"q": "QUERY"
1647+
}'
1648+
federated_search_multi_search_1: |-
1649+
curl \
1650+
-X POST 'MEILISEARCH_URL/multi-search' \
1651+
-H 'Content-Type: application/json' \
1652+
--data-binary '{
1653+
"federation": {},
1654+
"queries": [
1655+
{
1656+
"indexUid": "chats",
1657+
"q": "natasha"
1658+
},
1659+
{
1660+
"indexUid": "profiles",
1661+
"q": "natasha"
1662+
},
1663+
{
1664+
"indexUid": "tickets",
1665+
"q": "natasha"
1666+
}
1667+
]
1668+
}'
1669+
federated_search_multi_search_weight_1: |-
1670+
curl \
1671+
-X POST 'MEILISEARCH_URL/multi-search' \
1672+
-H 'Content-Type: application/json' \
1673+
--data-binary '{
1674+
"federation": {},
1675+
"queries": [
1676+
{
1677+
"indexUid": "chats",
1678+
"q": "rotondo"
1679+
},
1680+
{
1681+
"indexUid": "profiles",
1682+
"q": "rotondo",
1683+
"federationOptions": { "weight": 1.2 }
1684+
},
1685+
{
1686+
"indexUid": "tickets",
1687+
"q": "rotondo"
1688+
}
1689+
]
1690+
}'
1691+
chat_create_key_1: |-
1692+
curl \
1693+
-X POST 'MEILISEARCH_URL/keys' \
1694+
-H 'Authorization: Bearer MEILISEARCH_KEY' \
1695+
-H 'Content-Type: application/json' \
1696+
--data-binary '{
1697+
"name": "Chat API Key",
1698+
"description": "API key for chat completions",
1699+
"actions": ["search", "chatCompletions"],
1700+
"indexes": ["*"],
1701+
"expiresAt": null
1702+
}'
1703+
chat_index_settings_1: |-
1704+
curl \
1705+
-X PATCH 'MEILISEARCH_URL/indexes/INDEX_NAME/settings' \
1706+
-H 'Authorization: Bearer MEILISEARCH_KEY' \
1707+
-H 'Content-Type: application/json' \
1708+
--data-binary '{
1709+
"chat": {
1710+
"description": "A comprehensive database of TYPE_OF_DOCUMENT containing titles, descriptions, genres, and release dates to help users searching for TYPE_OF_DOCUMENT",
1711+
"documentTemplate": "{% for field in fields %}{% if field.is_searchable and field.value != nil %}{{ field.name }}: {{ field.value }}\n{% endif %}{% endfor %}",
1712+
"documentTemplateMaxBytes": 400
1713+
}
1714+
}'
1715+
chat_completions_1: |-
1716+
curl -N \
1717+
-X POST 'MEILISEARCH_URL/chats/WORKSPACE_NAME/chat/completions' \
1718+
-H 'Authorization: Bearer MEILISEARCH_API_KEY' \
1719+
-H 'Content-Type: application/json' \
1720+
--data-binary '{
1721+
"model": "PROVIDER_MODEL_UID",
1722+
"messages": [
1723+
{
1724+
"role": "user",
1725+
"content": "USER_PROMPT"
1726+
}
1727+
],
1728+
"tools": [
1729+
{
1730+
"type": "function",
1731+
"function": {
1732+
"name": "_meiliSearchProgress",
1733+
"description": "Reports real-time search progress to the user"
1734+
}
1735+
},
1736+
{
1737+
"type": "function",
1738+
"function": {
1739+
"name": "_meiliSearchSources",
1740+
"description": "Provides sources and references for the information"
1741+
}
1742+
}
1743+
]
1744+
}'
1745+
chat_get_settings_1: |-
1746+
curl \
1747+
-X GET 'MEILISEARCH_URL/chats/WORKSPACE_NAME/settings' \
1748+
-H "Authorization: Bearer MEILISEARCH_KEY"
1749+
chat_patch_settings_1: |-
1750+
curl \
1751+
-X PATCH 'MEILISEARCH_URL/chats/WORKSPACE_NAME/settings' \
1752+
-H "Authorization: Bearer MEILISEARCH_KEY" \
1753+
-H "Content-Type: application/json" \
1754+
--data-binary '{ "apiKey": "your-valid-api-key" }'
1755+
image_search_multimodal_settings_1: |-
1756+
curl \
1757+
-X PATCH 'MEILISEARCH_URL/indexes/INDEX_NAME/settings' \
1758+
-H 'Content-Type: application/json' \
1759+
--data-binary '{
1760+
"embedders": {
1761+
"MULTIMODAL_EMBEDDER_NAME": {
1762+
"source": "rest",
1763+
"url": "https://api.voyageai.com/v1/multimodal-embeddings",
1764+
"apiKey": "VOYAGE_API_KEY",
1765+
"indexingFragments": {
1766+
"TEXTUAL_FRAGMENT_NAME": {
1767+
"value": {
1768+
"content": [
1769+
{
1770+
"type": "text",
1771+
"text": "A document named {{doc.title}} described as {{doc.description}}"
1772+
}
1773+
]
1774+
}
1775+
},
1776+
"IMAGE_FRAGMENT_NAME": {
1777+
"value": {
1778+
"content": [
1779+
{
1780+
"type": "image_url",
1781+
"image_url": "{{doc.poster_url}}"
1782+
}
1783+
]
1784+
}
1785+
}
1786+
},
1787+
"searchFragments": {
1788+
"USER_TEXT_FRAGMENT": {
1789+
"value": {
1790+
"content": [
1791+
{
1792+
"type": "text",
1793+
"text": "{{q}}"
1794+
}
1795+
]
1796+
}
1797+
},
1798+
"USER_SUBMITTED_IMAGE_FRAGMENT": {
1799+
"value": {
1800+
"content": [
1801+
{
1802+
"type": "image_base64",
1803+
"image_base64": "data:{{media.image.mime}};base64,{{media.image.data}}"
1804+
}
1805+
]
1806+
}
1807+
}
1808+
},
1809+
"request": {
1810+
"inputs": ["{{fragment}}", "{{..}}"],
1811+
"model": "voyage-multimodal-3"
1812+
},
1813+
"response": {
1814+
"data": [
1815+
{ "embedding": "{{embedding}}" },
1816+
"{{..}}"
1817+
]
1818+
}
1819+
}
1820+
}
1821+
}'
1822+
image_search_multimodal_search_text_1: |-
1823+
curl \
1824+
-X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \
1825+
-H 'Content-Type: application/json' \
1826+
--data-binary '{
1827+
"q": "a mountain sunset with snow",
1828+
"hybrid": {
1829+
"embedder": "MULTIMODAL_EMBEDDER_NAME"
1830+
}
1831+
}'
1832+
image_search_multimodal_search_image_1: |-
1833+
curl \
1834+
-X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \
1835+
-H 'Content-Type: application/json' \
1836+
--data-binary '{
1837+
"media": {
1838+
"image": {
1839+
"mime": "image/jpeg",
1840+
"data": "<BASE64_ENCODED_IMAGE>"
1841+
}
1842+
},
1843+
"hybrid": {
1844+
"embedder": "MULTIMODAL_EMBEDDER_NAME"
1845+
}
1846+
}'
1847+
ai_search_getting_started_embedders_1: |-
1848+
curl \
1849+
-X PATCH 'MEILISEARCH_URL/indexes/kitchenware/settings/embedders' \
1850+
-H 'Content-Type: application/json' \
1851+
--data-binary '{
1852+
"products-openai": {
1853+
"source": "openAi",
1854+
"apiKey": "OPEN_AI_API_KEY",
1855+
"model": "text-embedding-3-small",
1856+
"documentTemplate": "An object used in a kitchen named '\''{{doc.name}}'\''"
1857+
}
1858+
}'
1859+
ai_search_getting_started_search_1: |-
1860+
curl \
1861+
-X POST 'MEILISEARCH_URL/indexes/kitchenware/search' \
1862+
-H 'Content-Type: application/json' \
1863+
--data-binary '{
1864+
"q": "kitchen utensils made of wood",
1865+
"hybrid": {
1866+
"embedder": "products-openai"
1867+
}
1868+
}'
1869+
personalization_search_1: |-
1870+
curl \
1871+
-X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \
1872+
-H 'Content-Type: application/json' \
1873+
--data-binary '{
1874+
"q": "wireless keyboard",
1875+
"personalize": {
1876+
"userContext": "The user prefers compact mechanical keyboards from Keychron or Logitech, with a mid-range budget and quiet keys for remote work."
1877+
}
1878+
}'
1879+
configure_rest_embedder_1: |-
1880+
curl \
1881+
-X PATCH 'MEILISEARCH_URL/indexes/INDEX_NAME/settings/embedders' \
1882+
-H 'Content-Type: application/json' \
1883+
--data-binary '{
1884+
"EMBEDDER_NAME": {
1885+
"source": "rest",
1886+
"url": "PROVIDER_URL",
1887+
"request": {
1888+
"model": "MODEL_NAME",
1889+
"input": ["{{text}}", "{{..}}"]
1890+
},
1891+
"response": {
1892+
"data": [
1893+
{ "embedding": "{{embedding}}" },
1894+
"{{..}}"
1895+
]
1896+
},
1897+
"apiKey": "PROVIDER_API_KEY",
1898+
"documentTemplate": "SHORT_AND_RELEVANT_DOCUMENT_TEMPLATE"
1899+
}
1900+
}'

0 commit comments

Comments
 (0)