Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 0 additions & 170 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -260,18 +260,6 @@ update_displayed_attributes_1: |-
});
reset_displayed_attributes_1: |-
client.index("movies").resetDisplayedAttributesSettings();
getting_started_typo_tolerance: |-
HashMap<String, Integer> minWordSizeTypos =
new HashMap<String, Integer>() {
{
put("oneTypo", 4);
}
};

TypoTolerance typoTolerance = new TypoTolerance();
typoTolerance.setMinWordSizeForTypos(minWordSizeTypos);

client.index("movies").updateTypoToleranceSettings(typoTolerance);
get_typo_tolerance_1:
client.index("books").getTypoToleranceSettings();
update_typo_tolerance_1: |-
Expand Down Expand Up @@ -469,10 +457,6 @@ typo_tolerance_guide_4: |-
};
typoTolerance.setMinWordSizeForTypos(minWordSizeTypos);
client.index("movies").updateTypoToleranceSettings(typoTolerance);
typo_tolerance_guide_5: |-
TypoTolerance typoTolerance = new TypoTolerance();
typoTolerance.setDisableOnNumbers(true);
client.index("movies").updateTypoToleranceSettings(typoTolerance);
getting_started_add_documents: |-
// For Maven:
// Add the following code to the `<dependencies>` section of your project:
Expand Down Expand Up @@ -503,88 +487,6 @@ getting_started_check_task_status: |-
client.getTask(0);
getting_started_search: |-
client.index("movies").search("botman");
getting_started_add_meteorites: |-
import com.meilisearch.sdk;
import org.json.JSONArray;
import java.nio.file.Files;
import java.nio.file.Path;

Path fileName = Path.of("meteorites.json");
String meteoritesJson = Files.readString(fileName);
Client client = new Client(new Config("http://localhost:7700", "masterKey"));

client.index("meteorites").addDocuments(meteoritesJson);
getting_started_update_ranking_rules: |-
Settings settings = new Settings();
settings.setRankingRules(new String[]
{
"exactness",
"words",
"typo",
"proximity",
"attribute",
"sort",
"release_date:asc",
"rank:desc"
});
client.index("movies").updateSettings(settings);
getting_started_update_displayed_attributes: |-
Settings settings = new Settings();
settings.setDisplayedAttributes(new String[]
{
"title",
"overview",
"poster"
});
client.index("movies").updateSettings(settings);
getting_started_update_searchable_attributes: |-
Settings settings = new Settings();
settings.setSearchableAttributes(new String[]
{
"title"
});
getting_started_update_stop_words: |-
Settings settings = new Settings();
settings.setStopWords(new String[]
{
"the"
});
client.index("movies").updateSettings(settings);
getting_started_synonyms: |-
Settings settings = new Settings();
HashMap<String, String[]> synonyms = new HashMap<String, String[]>();
synonyms.put("winnie", new String[] {"piglet"});
synonyms.put("piglet", new String[] {"winnie"});
settings.setSynonyms(synonyms);
client.index("movies").updateSettings(settings);
getting_started_filtering: |-
SearchRequest searchRequest = SearchRequest.builder().q("").filter(new String[] {"mass < 200"}).build();
client.index("meteorites").search(searchRequest);
getting_started_geo_radius: |-
SearchRequest searchRequest = SearchRequest.builder().q("").filter(new String[] {"_geoRadius(46.9480, 7.4474, 210000)"}).build();
client.index("meteorites").search(searchRequest);
getting_started_geo_point: |-
SearchRequest searchRequest = SearchRequest.builder().q("").sort(new String[] {"_geoPoint(48.8583701,2.2922926):asc"}).build();
client.index("meteorites").search(searchRequest);
getting_started_sorting: |-
SearchRequest searchRequest = SearchRequest.builder().q("").filter(new String[] {"mass < 200"}).sort(new String[] {"mass:asc"}).build();
client.index("meteorites").search(searchRequest);
getting_started_configure_settings: |-
Settings settings = new Settings();
settings.setFilterableAttributes(new String[] { "mass", "_geo" });
settings.setSortableAttributes(new String[] {"mass", "_geo"});
client.index("meteorites").updateSettings(settings);
getting_started_faceting: |-
Faceting newFaceting = new Faceting();
newFaceting.setMaxValuesPerFacet(2);
HashMap<String, FacetSortValue> facetSortValues = new HashMap<>();
facetSortValues.put("*", FacetSortValue.COUNT);
newFaceting.setSortFacetValuesBy(facetSortValues);
client.index("movies").updateFacetingSettings(newFaceting);
getting_started_pagination: |-
Pagination newPagination = new Pagination();
newPagination.setMaxTotalHits(500);
client.index("movies").updatePaginationSettings(newPagination);
filtering_update_settings_1: |-
client.index("movies").updateFilterableAttributesSettings(new String[]
{
Expand Down Expand Up @@ -630,18 +532,6 @@ add_movies_json_1: |-
Client client = new Client(new Config("http://localhost:7700", "masterKey"));
Index index = client.index("movies");
index.addDocuments(moviesJson);
landing_getting_started_1: |-
Client client = new Client(new Config("http://localhost:7700", "masterKey"));

client.index("movies").addDocuments("["
+ "{\"id\": 1, \"title\": \"Carol\"},"
+ "{\"id\": 2, \"title\": \"Wonder Woman\"},"
+ "{\"id\": 3, \"title\": \"Life of Pi\"},"
+ "{\"id\": 4, \"title\": \"Mad Max: Fury Road\"},"
+ "{\"id\": 5, \"title\": \"Moana\"},"
+ "{\"id\": 6, \"title\": \"Philadelphia\"}"
+ "]"
);
post_dump_1: |-
client.createDump();
create_snapshot_1: |-
Expand Down Expand Up @@ -731,51 +621,9 @@ primary_field_guide_add_document_primary_key: |-
+ "\"price\": 5.00"
+ "}]"
, "reference_number");
security_guide_search_key_1: |-
Client client = new Client(new Config("http://localhost:7700", "apiKey"));
client.index("patient_medical_records").search();
security_guide_update_key_1: |-
Client client = new Client(new Config("http://localhost:7700", "masterKey"));
client.updateKey("74c9c733-3368-4738-bbe5-1d18a5fecb37", new KeyUpdate().setDescription("Default Search API Key"));
security_guide_create_key_1: |-
Client client = new Client(new Config("http://localhost:7700", "masterKey"));

SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
Date dateParsed = format.parse("2023-01-01T00:00:00Z");

Key keyInfo = new Key();

keyInfo.setDescription("Search patient records key");
keyInfo.setActions(new String[] {"search"});
keyInfo.setIndexes(new String[] {"patient_medical_records"});
keyInfo.setExpiresAt(dateParsed);

client.createKey(keyInfo);
security_guide_list_keys_1: |-
Client client = new Client(new Config("http://localhost:7700", "masterKey"));
client.getKeys();
security_guide_delete_key_1: |-
Client client = new Client(new Config("http://localhost:7700", "masterKey"));
client.deleteKey("c5cd97d-5a4b-4226-a868-2d0eb6d197ab");
authorization_header_1: |-
Client client = new Client(new Config("http://localhost:7700", "masterKey"));
client.getKeys();
tenant_token_guide_generate_sdk_1: |-
Map<String, Object> filters = new HashMap<String, Object>();
filters.put("filter", "user_id = 1");
Map<String, Object> searchRules = new HashMap<String, Object>();
searchRules.put("patient_medical_records", filters);

Date expiresAt = new SimpleDateFormat("yyyy-MM-dd").parse("2025-12-20");
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
TenantTokenOptions options = new TenantTokenOptions();
options.setApiKey("B5KdX2MY2jV6EXfUs6scSfmC...");
options.setExpiresAt(expiresAt);

String token = client.generateTenantToken("85c3c2f9-bdd6-41f1-abd8-11fcf80e0f76", searchRules, options);
tenant_token_guide_search_sdk_1: |-
Client frontEndClient = new Client(new Config("http://localhost:7700", token));
frontEndClient.index("patient_medical_records").search("blood test");
date_guide_index_1: |-
import com.meilisearch.sdk;
import org.json.JSONArray;
Expand All @@ -799,35 +647,17 @@ date_guide_sortable_attributes_1: |-
date_guide_sort_1: |-
SearchRequest searchRequest = SearchRequest.builder().q("").sort(new String[] {"release_timestamp:desc"}).build();
client.index("games").search(searchRequest);
async_guide_filter_by_date_1: |-
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
Date date = format.parse("2020-10-11T11:49:53.000Z");
TasksQuery query = new TasksQuery().setBeforeEnqueuedAt(date);

client.getTasks(query);
async_guide_multiple_filters_1: |-
TasksQuery query =
new TasksQuery()
.setStatuses(new String[] {"processing"})
.setTypes(new String[] {"documentAdditionOrUpdate", "documentDeletion"})
.setIndexUids(new String[] {"movies"});

client.getTasks(query);
async_guide_filter_by_ids_1: |-
TasksQuery query = new TasksQuery().setUids(new int[] {5, 10, 13});
client.getTasks(query);
async_guide_filter_by_statuses_1: |-
TasksQuery query = new TasksQuery().setStatuses(new String[] {"failed", "canceled"});
client.getTasks(query);
async_guide_filter_by_types_1: |-
TasksQuery query = new TasksQuery().setTypes(new String[] {"dumpCreation", "indexSwap"});
client.getTasks(query);
async_guide_filter_by_index_uids_1: |-
TasksQuery query = new TasksQuery().setIndexUids(new String[] {"movies"});
client.getTasks(query);
async_guide_canceled_by_1: |-
TasksQuery query = new TasksQuery().setCanceledBy(new int[] {9, 15});
client.getTasks(query);
multi_search_1: |-
MultiSearchRequest multiSearchRequest = new MultiSearchRequest();
multiIndexSearch.addQuery(new IndexSearchRequest("movies").setQuery("pooh").setLimit(5));
Expand Down