diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index 02e15988..574b3559 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -13,7 +13,7 @@ create_an_index_1: |- PrimaryKey: "movie_id", }) update_an_index_1: |- - client.Index("movies").UpdateIndex(response.UID, "movie_id") + client.Index("movies").UpdateIndex("movie_review_id") delete_an_index_1: |- client.DeleteIndex("movies") // OR @@ -23,7 +23,7 @@ get_one_document_1: |- client.Index("movies").GetDocument("25684", &a) get_documents_1: |- var a []interface{} - client.Index("movies").GetDocuments(meilisearch.DocumentsRequest{ + client.Index("movies").GetDocuments(&meilisearch.DocumentsRequest{ Limit: 2, }, &a) add_or_replace_documents_1: |- @@ -41,7 +41,7 @@ add_or_update_documents_1: |- documents := []map[string]interface{}{ { "id": 287947, - "title": "Shazam", + "title": "Shazam ⚡️", "genres": "comedy", }, } @@ -58,11 +58,11 @@ delete_documents_1: |- "363869", }) search_post_1: |- - client.Index("movies").Search(SearchRequest{ - Query: "American ninja", - }) + client.Index("movies").Search("american ninja", nil) +search_get_1: |- + get_update_1: |- - client.Index("movies").GetUpdateStatus(0) + client.Index("movies").GetUpdateStatus(1) get_all_updates_1: |- client.Index("movies").GetAllUpdateStatus() get_keys_1: |- @@ -73,11 +73,10 @@ update_settings_1: |- distinctAttribute := "movie_id" settings := meilisearch.Settings{ RankingRules: []string{ - "typo", "words", + "typo", "proximity", "attribute", - "wordsPosition", "exactness", "desc(release_date)", "desc(rank)", @@ -122,18 +121,17 @@ get_stop_words_1: |- client.Index("movies").GetStopWords() update_stop_words_1: |- stopWords := []string{"of", "the", "to"} - client.Index("movies").UpdateStopWords(stopWords) + client.Index("movies").UpdateStopWords(&stopWords) reset_stop_words_1: |- client.Index("movies").ResetStopWords() get_ranking_rules_1: |- client.Index("movies").GetRankingRules() update_ranking_rules_1: |- rankingRules := []string{ - "typo", "words", + "typo", "proximity", "attribute", - "wordsPosition", "exactness", "asc(release_date)", "desc(rank)", @@ -147,6 +145,16 @@ update_distinct_attribute_1: |- client.Index("movies").UpdateDistinctAttribute("movie_id") reset_distinct_attribute_1: |- client.Index("movies").ResetDistinctAttribute() +get_filterable_attributes_1: |- + client.Index("movies").GetFilterableAttributes() +update_filterable_attributes_1: |- + filterableAttributes := []string{ + "genres", + "director", + } + client.Index("movies").UpdateFilterableAttributes(&filterableAttributes) +reset_filterable_attributes_1: |- + client.Index("movies").ResetFilterableAttributes() get_searchable_attributes_1: |- client.Index("movies").GetSearchableAttributes() update_searchable_attributes_1: |- @@ -158,16 +166,6 @@ update_searchable_attributes_1: |- client.Index("movies").UpdateSearchableAttributes(&searchableAttributes) reset_searchable_attributes_1: |- client.Index("movies").ResetSearchableAttributes() -get_attributes_for_faceting_1: |- - client.Index("movies").GetFilterableAttributes() -update_attributes_for_faceting_1: |- - filterableAttributes := []string{ - "genres", - "director", - } - client.Index("movies").UpdateFilterableAttributes(&filterableAttributes) -reset_attributes_for_faceting_1: |- - client.Index("movies").ResetFilterableAttributes() get_displayed_attributes_1: |- client.Index("movies").GetDisplayedAttributes() update_displayed_attributes_1: |- @@ -196,7 +194,7 @@ field_properties_guide_searchable_1: |- "description", "genre", } - client.Index("movies").UpdateSearchableAttributes(searchableAttributes) + client.Index("movies").UpdateSearchableAttributes(&searchableAttributes) field_properties_guide_displayed_1: |- displayedAttributes := []string{ "title", @@ -204,72 +202,56 @@ field_properties_guide_displayed_1: |- "genre", "release_date", } - client.Index("movies").UpdateDisplayedAttributes(displayedAttributes) + client.Index("movies").UpdateDisplayedAttributes(&displayedAttributes) filtering_guide_1: |- - results, error := client.Index("movies").Search(meilisearch.SearchRequest{ - Query: "Avengers", + results, err := client.Index("movies").Search("Avengers", &meilisearch.SearchRequest{ Filter: "release_date > \"795484800\"", }) filtering_guide_2: |- - results, error := client.Index("movies").Search(meilisearch.SearchRequest{ - Query: "Batman", + results, err := client.Index("movies").Search("Batman", &meilisearch.SearchRequest{ Filter: "release_date > 795484800 AND (director = \"Tim Burton\" OR director = \"Christopher Nolan\")", }) filtering_guide_3: |- - results, error := client.Index("movies").Search(meilisearch.SearchRequest{ - Query: "horror", + results, err := client.Index("movies").Search("horror", &meilisearch.SearchRequest{ Filter: "director = \"Jordan Peele\"", }) filtering_guide_4: |- - results, error := client.Index("movies").Search(meilisearch.SearchRequest{ - Query: "Planet of the Apes", + results, err := client.Index("movies").Search("Planet of the Apes", &meilisearch.SearchRequest{ Filter: "rating >= 3 AND (NOT director = \"Tim Burton\"", }) search_parameter_guide_query_1: |- - results, error := client.Index("movies").Search(meilisearch.SearchRequest{ - Query: "shifu", - }) + results, err := client.Index("movies").Search("shifu", &meilisearch.SearchRequest{}) search_parameter_guide_offset_1: |- - results, error := client.Index("movies").Search(meilisearch.SearchRequest{ - Query: "shifu", + results, err := client.Index("movies").Search("shifu", &meilisearch.SearchRequest{ Offset: 1, }) search_parameter_guide_limit_1: |- - results, error := client.Index("movies").Search(meilisearch.SearchRequest{ - Query: "shifu", + results, err := client.Index("movies").Search("shifu", &meilisearch.SearchRequest{ Limit: 2, }) search_parameter_guide_retrieve_1: |- - results, error := client.Index("movies").Search(meilisearch.SearchRequest{ - Query: "shifu", + results, err := client.Index("movies").Search("shifu", &meilisearch.SearchRequest{ AttributesToRetrieve: []string{"overview", "title"}, }) search_parameter_guide_crop_1: |- - results, error := client.Index("movies").Search(meilisearch.SearchRequest{ - Query: "shifu", + results, err := client.Index("movies").Search("shifu" &meilisearch.SearchRequest{ AttributesToCrop: []string{"overview"}, CropLength: 10, }) search_parameter_guide_highlight_1: |- - results, error := client.Index("movies").Search(meilisearch.SearchRequest{ - Query: "shifu", + results, err := client.Index("movies").Search("winter feast", &meilisearch.SearchRequest{ AttributesToHighlight: []string{"overview"}, }) search_parameter_guide_filter_1: |- - results, error := client.Index("movies").Search(meilisearch.SearchRequest{ - Query: "n", + results, err := client.Index("movies").Search("n", &meilisearch.SearchRequest{ Filter: "title = Nightshift", }) search_parameter_guide_filter_2: |- - results, error := client.Index("movies").Search(meilisearch.SearchRequest{ - Query: "n", - Filter: "title=\"Kung Fu Panda\"", + results, err := client.Index("movies").Search("n", &meilisearch.SearchRequest{ + Filter: "title = \"Kung Fu Panda\"", }) search_parameter_guide_matches_1: |- - results, error := client.Index("movies").Search(meilisearch.SearchRequest{ - Query: "n", - Filter: "title=\"Kung Fu Panda\"", - AttributesToHighlight: []string{"overview"}, + results, err := client.Index("movies").Search("winter feast", &meilisearch.SearchRequest{ Matches: true, }) settings_guide_synonyms_1: |- @@ -277,22 +259,21 @@ settings_guide_synonyms_1: |- "sweater": []string{"jumper"}, "jumper": []string{"sweater"}, } - client.Index("movies").UpdateSynonyms(synonyms) + client.Index("movies").UpdateSynonyms(&synonyms) settings_guide_stop_words_1: |- stopWords := []string{"the", "a", "an"} - client.Index("movies").UpdateStopWords(stopWords) + client.Index("movies").UpdateStopWords(&stopWords) settings_guide_ranking_rules_1: |- rankingRules := []string{ - "typo", "words", + "typo", "proximity", "attribute", - "wordsPosition", "exactness", "asc(release_date)", "desc(rank)", } - client.Index("movies").UpdateRankingRules(rankingRules) + client.Index("movies").UpdateRankingRules(&rankingRules) settings_guide_distinct_1: |- client.Index("movies").UpdateDistinctAttribute("movie_id") settings_guide_searchable_1: |- @@ -301,7 +282,7 @@ settings_guide_searchable_1: |- "description", "genre", } - client.Index("movies").UpdateSearchableAttributes(searchableAttributes) + client.Index("movies").UpdateSearchableAttributes(&searchableAttributes) settings_guide_displayed_1: |- displayedAttributes := []string{ "title", @@ -309,7 +290,19 @@ settings_guide_displayed_1: |- "genre", "release_date", } - client.Index("movies").UpdateDisplayedAttributes(displayedAttributes) + client.Index("movies").UpdateDisplayedAttributes(&displayedAttributes) +add_movies_json_1: |- + import ( + "encoding/json" + "io/ioutil" + ) + + file, _ := ioutil.ReadFile("movies.json") + + var movies interface{} + json.Unmarshal([]byte(file), &movies) + + index.AddDocuments(&movies) documents_guide_add_movie_1: |- documents := []map[string]interface{}{ { @@ -319,14 +312,12 @@ documents_guide_add_movie_1: |- } client.Index("movies").AddDocuments(documents) search_guide_1: |- - results, error := client.Index("movies").Search(meilisearch.SearchRequest{ - Query: "shifu", + results, err := client.Index("movies").Search("shifu", &meilisearch.SearchRequest{ Limit: 5, Offset: 10, }) search_guide_2: |- - results, error := client.Index("movies").Search(meilisearch.SearchRequest{ - Query: "Avengers", + results, err := client.Index("movies").Search("Avengers", &meilisearch.SearchRequest{ Filter: "release_date > \"795484800\"", }) getting_started_add_documents_md: |- @@ -346,7 +337,7 @@ getting_started_add_documents_md: |- ) func main() { - client = meilisearch.NewClient(meilisearch.ClientConfig{ + client := meilisearch.NewClient(meilisearch.ClientConfig{ Host: "http://127.0.0.1:7700", }) @@ -357,7 +348,7 @@ getting_started_add_documents_md: |- var movies []map[string]interface{} json.Unmarshal(byteValue, &movies) - update, err := client.Index("movies").AddDocuments(movies) + _, err := client.Index("movies").AddDocuments(movies) if err != nil { panic(err) } @@ -367,9 +358,7 @@ getting_started_add_documents_md: |- [About this SDK](https://github.com/meilisearch/meilisearch-go/) getting_started_search_md: |- ```go - results, err := client.Index("movies").Search(meilisearch.SearchRequest{ - Query: "botman", - }) + results, err := client.Index("movies").Search("botman", &meilisearch.SearchRequest{}) if err != nil { panic(err) } @@ -377,60 +366,46 @@ getting_started_search_md: |- [About this SDK](https://github.com/meilisearch/meilisearch-go/) faceted_search_update_settings_1: |- - response, error := client.Index("movies").UpdateAttributesForFaceting([]string{ + response, err := client.Index("movies").UpdateFilterableAttributes(&[]string{ "director", "genres", }) -# faceted_search_facet_filters_1: |- -# results, error := client.Index("movies").Search(meilisearch.SearchRequest{ -# Query: "thriller", -# FacetFilter: [][]string{ -# []string{"genres:Horror", "genres:Mystery"}, -# []string{"director:Jordan Peele"}, -# }, -# }) +faceted_search_filter_1: |- + results, err := client.Index("movies").Search("thriller", &meilisearch.SearchRequest{ + Filter: [][]string{ + []string{"genres = Horror", "genres = Mystery"}, + []string{"director = \"Jordan Peele\""}, + }, + }) faceted_search_facets_distribution_1: |- - results, error := client.Index("movies").Search(meilisearch.SearchRequest{ - Query: "Batman", + results, err := client.Index("movies").Search("Batman", &meilisearch.SearchRequest{ FacetsDistribution: []string{ "genres", }, }) -faceted_search_walkthrough_attributes_for_faceting_1: |- - response, error := client.Index("movies").UpdateAttributesForFaceting([]string{ +faceted_search_walkthrough_filterable_attributes_1: |- + response, err := client.Index("movies").UpdateFilterableAttributes(&[]string{ "director", "producer", "genres", "production_companies", }) -# faceted_search_walkthrough_facet_filters_1: |- -# results, error := client.Index("movies").Search(meilisearch.SearchRequest{ -# Query: "thriller", -# FacetFilter: [][]string{ -# []string{"genres:Horror", "genres:Mystery"}, -# []string{"director:Jordan Peele"}, -# }, -# }) +faceted_search_walkthrough_filter_1: |- + results, err := client.Index("movies").Search("thriller", &meilisearch.SearchRequest{ + Filter: [][]string{ + []string{"genres = Horror", "genres = Mystery"}, + []string{"director = \"Jordan Peele\""}, + }, + }) faceted_search_walkthrough_facets_distribution_1: |- - results, error := client.Index("movies").Search(meilisearch.SearchRequest{ - Query: "Batman", + results, err := client.Index("movies").Search("Batman", &meilisearch.SearchRequest{ FacetsDistribution: []string{ "genres", }, }) post_dump_1: |- - results, error := client.CreateDump() + results, err := client.CreateDump() get_dump_status_1: |- - results, error := client.GetDumpStatus("dump-uid") -add_movies_json_1: |- - import ( - "encoding/json" - "io/ioutil" - ) - - file, _ := ioutil.ReadFile("movies.json") - - var movies interface{} - json.Unmarshal([]byte(file), &movies) - - index.AddDocuments(&movies) + results, err := client.GetDumpStatus("dump-uid") +phrase_search_1: |- +results, err := client.Index("movies").Search("\"neo\"", &meilisearch.SearchRequest{})