Skip to content

Update code samples #291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 20, 2021
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
90 changes: 44 additions & 46 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ delete_documents_1: |-
client.index('movies').delete_documents([23488, 153738, 437035, 363869])
search_post_1: |-
client.index('movies').search('American ninja')
search_get_1: |-
client.index('movies').search('American ninja')
get_update_1: |-
client.index('movies').get_update_status(1)
get_all_updates_1: |-
Expand All @@ -50,11 +52,10 @@ get_settings_1: |-
update_settings_1: |-
client.index('movies').update_settings({
'rankingRules': [
'typo',
'words',
'typo',
'proximity',
'attribute',
'wordsPosition',
'exactness',
'desc(release_date)',
'desc(rank)'
Expand Down Expand Up @@ -104,11 +105,10 @@ get_ranking_rules_1: |-
client.index('movies').get_ranking_rules()
update_ranking_rules_1: |-
client.index('movies').update_ranking_rules([
'typo',
'words',
'typo',
'proximity',
'attribute',
'wordsPosition',
'exactness',
'asc(release_date)',
'desc(rank)'
Expand All @@ -121,6 +121,15 @@ update_distinct_attribute_1: |-
client.index('movies').update_distinct_attribute('movie_id')
reset_distinct_attribute_1: |-
client.index('movies').reset_distinct_attribute()
get_filterable_attributes_1: |-
client.index('movies').get_filterable_attributes()
update_filterable_attributes_1: |-
client.index('movies').update_filterable_attributes([
'genres',
'director'
])
reset_filterable_attributes_1: |-
client.index('movies').reset_filterable_attributes()
get_searchable_attributes_1: |-
client.index('movies').get_searchable_attributes()
update_searchable_attributes_1: |-
Expand All @@ -135,11 +144,10 @@ get_displayed_attributes_1: |-
client.index('movies').get_displayed_attributes()
update_displayed_attributes_1: |-
client.index('movies').update_displayed_attributes([
"title",
'title',
'description',
'release_date',
'rank',
'poster'
'genre',
'release_date'
])
reset_displayed_attributes_1: |-
client.index('movies').reset_displayed_attributes()
Expand Down Expand Up @@ -170,19 +178,19 @@ field_properties_guide_displayed_1: |-
]})
filtering_guide_1: |-
client.index('movies').search('Avengers', {
'filters': 'release_date > 795484800'
'filter': 'release_date > 795484800'
})
filtering_guide_2: |-
client.index('movies').search('Batman', {
'filters': 'release_date > 795484800 AND (director = "Tim Burton" OR director = "Christopher Nolan")'
'filter': 'release_date > 795484800 AND (director = "Tim Burton" OR director = "Christopher Nolan")'
})
filtering_guide_3: |-
client.index('movies').search('horror', {
'filters': 'director = "Jordan Peele"'
'filter': 'director = "Jordan Peele"'
})
filtering_guide_4: |-
client.index('movies').search('Planet of the Apes', {
'filters': 'rating >= 3 AND (NOT director = "Tim Burton")'
'filter': 'rating >= 3 AND (NOT director = "Tim Burton")'
})
search_parameter_guide_query_1: |-
client.index('movies').search('shifu')
Expand All @@ -204,25 +212,23 @@ search_parameter_guide_crop_1: |-
'cropLength': 10
})
search_parameter_guide_highlight_1: |-
client.index('movies').search('shifu', {
client.index('movies').search('winter feast', {
'attributesToHighlight': ['overview']
})
search_parameter_guide_filter_1: |-
client.index('movies').search('n', {
'filters': 'title = Nightshift'
'filter': 'title = Nightshift'
})
search_parameter_guide_filter_2: |-
client.index('movies').search('n', {
'filters': 'title = "Kung Fu Panda"'
client.index('movies').search('shifu', {
'filter': 'title = "Kung Fu Panda"'
})
search_parameter_guide_matches_1: |-
client.index('movies').search('n', {
'filters': 'title = "Kung Fu Panda"',
'attributesToHighlight': ['overview'],
client.index('movies').search('winter feast', {
'matches': 'true'
})
settings_guide_synonyms_1: |-
client.index('movies').update_settings({
client.index('tops').update_settings({
'synonyms': {
sweater: ['jumper'],
jumper: ['sweater']
Expand All @@ -239,18 +245,17 @@ settings_guide_stop_words_1: |-
settings_guide_ranking_rules_1: |-
client.index('movies').update_settings({
'rankingRules': [
'typo',
'words',
'typo',
'proximity',
'attribute',
'wordsPosition',
'exactness',
'asc(release_date)',
'desc(rank)'
]
})
settings_guide_distinct_1: |-
client.index('movies').update_settings({
client.index('jackets').update_settings({
'distinctAttribute': 'product_id'
})
settings_guide_searchable_1: |-
Expand All @@ -270,6 +275,12 @@ settings_guide_displayed_1: |-
'release_date'
]
})
add_movies_json_1: |-
import json

json_file = open('movies.json')
movies = json.load(json_file)
client.index('movies').add_documents(movies)
documents_guide_add_movie_1: |-
client.index('movies').add_documents([{
'movie_id': '123sq178',
Expand All @@ -282,7 +293,7 @@ search_guide_1: |-
})
search_guide_2: |-
client.index('movies').search('Avengers', {
'filters': 'release_date > 795484800'
'filter': 'release_date > 795484800'
})
getting_started_add_documents_md: |-
```bash
Expand All @@ -308,28 +319,28 @@ getting_started_search_md: |-

[About this SDK](https://github.com/meilisearch/meilisearch-python/)
faceted_search_update_settings_1: |-
client.index('movies').update_attributes_for_faceting([
client.index('movies').update_filterable_attributes([
'director',
'genres',
])
faceted_search_facet_filters_1: |-
faceted_search_filter_1: |-
client.index('movies').search('thriller', {
'facetFilters': [['genres:Horror', 'genres:Mystery'], 'director:Jordan Peele']
'filter': [['genres = Horror', 'genres = Mystery'], 'director = Jordan Peele']
})
faceted_search_facets_distribution_1: |-
client.index('movies').search('Batman', {
'facetsDistribution': ['genres']
})
faceted_search_walkthrough_attributes_for_faceting_1: |-
client.index('movies').update_attributes_for_faceting([
faceted_search_walkthrough_filterable_attributes_1: |-
client.index('movies').update_filterable_attributes([
'director',
'producer',
'genres',
'production_companies'
])
faceted_search_walkthrough_facet_filters_1: |-
faceted_search_walkthrough_filter_1: |-
client.index('movies').search('thriller', {
'facetFilters': [['genres:Horror', 'genres:Mystery'], 'director:Jordan Peele']
'filter': [['genres = Horror', 'genres = Mystery'], 'director = Jordan Peele']
})
faceted_search_walkthrough_facets_distribution_1: |-
client.index('movies').search('Batman', {
Expand All @@ -339,18 +350,5 @@ post_dump_1: |-
client.create_dump()
get_dump_status_1: |-
client.get_dump_status('20201101-110357260')
get_attributes_for_faceting_1: |-
client.index('movies').get_attributes_for_faceting()
update_attributes_for_faceting_1: |-
client.index('movies').update_attributes_for_faceting([
'genres',
'director'
])
reset_attributes_for_faceting_1: |-
client.index('movies').reset_attributes_for_faceting()
add_movies_json_1: |-
import json

json_file = open('movies.json')
movies = json.load(json_file)
client.index('movies').add_documents(movies)
phrase_search_1: |-
client.index('movies').search('"african american" horror')