Skip to content

Update code samples #427

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 12 commits into from
Apr 7, 2022
164 changes: 110 additions & 54 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ get_one_index_1: |-
list_all_indexes_1: |-
client.get_indexes()
create_an_index_1: |-
client.create_index('movies', {'primaryKey': 'movie_id'})
client.create_index('movies', {'primaryKey': 'id'})
update_an_index_1: |-
client.index('movies').update(primary_key='movie_review_id')
client.index('movies').update(primary_key='id')
delete_an_index_1: |-
client.delete_index('movies')
// OR
Expand Down Expand Up @@ -87,13 +87,13 @@ update_settings_1: |-
'distinctAttribute': 'movie_id',
'searchableAttributes': [
'title',
'description',
'genre'
'overview',
'genres'
],
'displayedAttributes': [
'title',
'description',
'genre',
'overview',
'genres',
'release_date'
],
'sortableAttributes': [
Expand Down Expand Up @@ -164,8 +164,8 @@ get_searchable_attributes_1: |-
update_searchable_attributes_1: |-
client.index('movies').update_searchable_attributes([
'title',
'description',
'uid'
'overview',
'genres'
])
reset_searchable_attributes_1: |-
client.index('movies').reset_searchable_attributes()
Expand All @@ -174,8 +174,8 @@ get_displayed_attributes_1: |-
update_displayed_attributes_1: |-
client.index('movies').update_displayed_attributes([
'title',
'description',
'genre',
'overview',
'genres',
'release_date'
])
reset_displayed_attributes_1: |-
Expand Down Expand Up @@ -203,15 +203,15 @@ field_properties_guide_searchable_1: |-
client.index('movies').update_settings({
'searchableAttributes': [
'title',
'description',
'genre'
'overview',
'genres'
]})
field_properties_guide_displayed_1: |-
client.index('movies').update_settings({
'displayedAttributes': [
'title',
'description',
'genre',
'overview',
'genres',
'release_date'
]})
filtering_guide_1: |-
Expand All @@ -223,10 +223,6 @@ filtering_guide_2: |-
'filter': 'release_date > 795484800 AND (director = "Tim Burton" OR director = "Christopher Nolan")'
})
filtering_guide_3: |-
client.index('movies').search('horror', {
'filter': 'director = "Jordan Peele"'
})
filtering_guide_4: |-
client.index('movies').search('Planet of the Apes', {
'filter': 'rating >= 3 AND (NOT director = "Tim Burton")'
})
Expand All @@ -253,14 +249,6 @@ search_parameter_guide_highlight_1: |-
client.index('movies').search('winter feast', {
'attributesToHighlight': ['overview']
})
search_parameter_guide_filter_1: |-
client.index('movies').search('n', {
'filter': 'title = Nightshift'
})
search_parameter_guide_filter_2: |-
client.index('movies').search('shifu', {
'filter': 'title = "Kung Fu Panda"'
})
search_parameter_guide_matches_1: |-
client.index('movies').search('winter feast', {
'matches': 'true'
Expand Down Expand Up @@ -301,16 +289,16 @@ settings_guide_searchable_1: |-
client.index('movies').update_settings({
'searchableAttributes': [
'title',
'description',
'genre'
'overview',
'genres'
]
})
settings_guide_displayed_1: |-
client.index('movies').update_settings({
'displayedAttributes': [
'title',
'description',
'genre',
'overview',
'genres',
'release_date'
]
})
Expand All @@ -327,20 +315,24 @@ add_movies_json_1: |-
json_file = open('movies.json')
movies = json.load(json_file)
client.index('movies').add_documents(movies)
landing_getting_started_1: |-
client = meilisearch.Client('http://127.0.0.1:7700', 'masterKey')

client.index('movies').add_documents([
{ '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'}
])
documents_guide_add_movie_1: |-
client.index('movies').add_documents([{
'movie_id': '123sq178',
'title': 'Amélie Poulain'
}])
search_guide_1: |-
client.index('movies').search('shifu', {
'limit': 5,
'offset': 10
})
search_guide_2: |-
client.index('movies').search('Avengers', {
'filter': 'release_date > 795484800'
})
getting_started_check_task_status: |-
client.index('movies').get_task(0)
getting_started_add_documents_md: |-
```bash
pip3 install meilisearch
Expand All @@ -364,6 +356,71 @@ getting_started_search_md: |-
```

[About this SDK](https://github.com/meilisearch/meilisearch-python/)
getting_started_add_meteorites: |-
import json

json_file = open('meteorites.json')
meteorites = json.load(json_file)
client.index('meteorites').add_documents(meteorites)
getting_started_update_rankingRules: |-
client.index('movies').update_ranking_rules([
'exactness',
'words',
'typo',
'proximity',
'attribute',
'sort',
'release_date:asc',
'rank:desc'
])
getting_started_update_displayedAttributes: |-
client.index('movies').update_displayed_attributes([
'title',
'overview',
'poster'
])
getting_started_update_searchableAttributes: |-
client.index('movies').update_searchable_attributes([
'title'
])
getting_started_update_stop_words: |-
client.index('movies').update_stop_words(['the'])
getting_started_synonyms: |-
client.index('movies').update_synonyms({
'winnie': ['piglet'],
'piglet': ['winnie']
})
getting_started_filtering: |-
client.index('meteorites').search('', {
'filter': 'mass < 200'
})
getting_started_geoRadius: |-
client.index('meteorites').search('', {
'filter': '_geoRadius(46.9480, 7.4474, 210000)'
})
getting_started_geoPoint: |-
client.index('meteorites').search('', {
'sort': ['_geoPoint(48.8583701,2.2922926):asc']
})
getting_started_sorting: |-
client.index('meteorites').search('', {
'filter': 'mass < 200',
'sort': ['mass:asc']
})
getting_started_configure_settings: |-
client.index('meteorites').update_settings({
'filterableAttributes': [
'mass',
'_geo'
],
'sortableAttributes': [
'mass',
'_geo'
]
})
getting_started_communicating_with_a_protected_instance: |-
client = Client('http://127.0.0.1:7700', 'apiKey')
client.index('movies').search()
faceted_search_update_settings_1: |-
client.index('movies').update_filterable_attributes([
'director',
Expand All @@ -377,21 +434,10 @@ faceted_search_facets_distribution_1: |-
client.index('movies').search('Batman', {
'facetsDistribution': ['genres']
})
faceted_search_walkthrough_filterable_attributes_1: |-
client.index('movies').update_filterable_attributes([
'director',
'producer',
'genres',
'production_companies'
])
faceted_search_walkthrough_filter_1: |-
client.index('movies').search('thriller', {
'filter': [['genres = Horror', 'genres = Mystery'], 'director = "Jordan Peele"']
})
faceted_search_walkthrough_facets_distribution_1: |-
client.index('movies').search('Batman', {
'facetsDistribution': ['genres']
})
post_dump_1: |-
client.create_dump()
get_dump_status_1: |-
Expand Down Expand Up @@ -430,24 +476,34 @@ geosearch_guide_filter_settings_1: |-
])
geosearch_guide_filter_usage_1: |-
client.index('restaurants').search('', {
'filter': '_geoRadius(45.4628328, 9.1076931, 2000)'
'filter': '_geoRadius(45.472735, 9.184019, 2000)'
})
geosearch_guide_filter_usage_2: |-
client.index('restaurants').search('', {
'filter': '_geoRadius(45.4628328, 9.1076931, 2000) AND type = pizza'
'filter': '_geoRadius(45.472735, 9.184019, 2000) AND type = pizza'
})
geosearch_guide_sort_settings_1: |-
client.index('restaurants').update_sortable_attributes([
'_geo'
])
geosearch_guide_sort_usage_1: |-
client.index('restaurants').search('', {
'sort': ['_geoPoint(48.8583701,2.2922926):asc']
'sort': ['_geoPoint(48.8561446,2.2978204):asc']
})
geosearch_guide_sort_usage_2: |-
client.index('restaurants').search('', {
'sort': ['_geoPoint(48.8583701,2.2922926):asc', 'rating:desc']
'sort': ['_geoPoint(48.8561446,2.2978204):asc', 'rating:desc']
})
document_guide_create_index_primary_key: |-
client.create_index('movies', {'primaryKey': 'reference_number'})
document_guide_add_document_primary_key: |-
client.index('movies').add_documents([{
'reference_number': 287947,
'title': 'Shazam',
'poster': 'https://image.tmdb.org/t/p/w1280/xnopI5Xtky18MPhK40cZAGAOVeV.jpg',
'overview': 'A boy is given the ability to become an adult superhero in times of need with a single magic word.',
'release_date': '2019-03-23'
}], 'reference_number')
security_guide_search_key_1: |-
client = Client('http://127.0.0.1:7700', 'apiKey')
client.index('patient_medical_records').search()
Expand Down