forked from meilisearch/meilisearch-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.code-samples.meilisearch.yaml
261 lines (250 loc) · 8.73 KB
/
.code-samples.meilisearch.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# This code-samples file is used by the MeiliSearch documentation
# Every example written here will be automatically fetched by
# the documentation on build
# You can read more on https://github.com/meilisearch/documentation/tree/master/.vuepress/code-samples
---
get_one_index_1: |-
list_all_indexes_1: |-
create_an_index_1: |-
update_an_index_1: |-
delete_an_index_1: |-
get_one_document_1: |-
get_documents_1: |-
add_or_replace_documents_1: |-
add_or_update_documents_1: |-
delete_all_documents_1: |-
delete_one_document_1: |-
delete_documents_1: |-
search_post_1: |-
get_update_1: |-
get_all_updates_1: |-
var updates = await client.Index("movies").GetAllUpdateStatus();
foreach (UpdateStatus update in updates)
{
Console.WriteLine(update.Status);
}
get_keys_1: |-
get_settings_1: |-
update_settings_1: |-
reset_settings_1: |-
get_synonyms_1: |-
update_synonyms_1: |-
reset_synonyms_1: |-
get_stop_words_1: |-
update_stop_words_1: |-
reset_stop_words_1: |-
get_ranking_rules_1: |-
update_ranking_rules_1: |-
reset_ranking_rules_1: |-
get_distinct_attribute_1: |-
string result = await client.Index("shoes").GetDistinctAttribute();
update_distinct_attribute_1: |-
UpdateStatus result = await client.Index("shoes").UpdateDistinctAttribute("skuid");
reset_distinct_attribute_1: |-
UpdateStatus result = await client.Index("shoes").ResetDistinctAttribute();
get_searchable_attributes_1: |-
update_searchable_attributes_1: |-
reset_searchable_attributes_1: |-
get_filterable_attributes_1: |-
IEnumerable<string> attributes = await client.Index("movies").GetFilterableAttributes();
foreach (string attribute in attributes)
{
Console.WriteLine(attribute);
}
update_filterable_attributes_1: |-
List<string> attributes = new() { "genres", "director" };
UpdateStatus result = await client.Index("movies").UpdateFilterableAttributes(attributes);
reset_filterable_attributes_1: |-
UpdateStatus result = await client.Index("movies").ResetFilterableAttributes();
get_displayed_attributes_1: |-
update_displayed_attributes_1: |-
reset_displayed_attributes_1: |-
get_index_stats_1: |-
get_indexes_stats_1: |-
get_health_1: |-
get_version_1: |-
distinct_attribute_guide_1: |-
field_properties_guide_searchable_1: |-
field_properties_guide_displayed_1: |-
filtering_guide_1: |-
SearchQuery filters = new SearchQuery() { Filter = "release_date > \"795484800\"" };
SearchResult<Movie> movies = await client.Index("movies").Search<Movie>("Avengers", filters);
foreach (var movie in movies.Hits)
{
Console.WriteLine(movie.Title);
}
filtering_guide_2: |-
SearchQuery filters = new SearchQuery() { Filter = "release_date > 795484800 AND (director =
\"Tim Burton\" OR director = \"Christopher Nolan\")" };
SearchResult<Movie> movies = await client.Index("movies").Search<Movie>("Batman", filters);
foreach (var movie in movies.Hits)
{
Console.WriteLine(movie.Title);
}
filtering_guide_3: |-
SearchQuery filters = new SearchQuery() { Filter = "director = \"Jordan Peele\"" };
SearchResult<Movie> movies = await client.Index("movies").Search<Movie>("horror", filters);
foreach (var movie in movies.Hits)
{
Console.WriteLine(movie.Title);
}
filtering_guide_4: |-
SearchQuery filters = new SearchQuery() { Filter = "rating >= 3 AND (NOT director = \"Tim Burton\"" };
SearchResult<Movie> movies = await client.Index("movies").Search<Movie>("Planet of the Apes", filters);
foreach (var movie in movies.Hits)
{
Console.WriteLine(movie.Title);
}
search_parameter_guide_query_1: |-
search_parameter_guide_offset_1: |-
search_parameter_guide_limit_1: |-
search_parameter_guide_retrieve_1: |-
search_parameter_guide_crop_1: |-
search_parameter_guide_highlight_1: |-
search_parameter_guide_filter_1: |-
search_parameter_guide_filter_2: |-
search_parameter_guide_matches_1: |-
settings_guide_synonyms_1: |-
settings_guide_stop_words_1: |-
settings_guide_ranking_rules_1: |-
settings_guide_distinct_1: |-
settings_guide_searchable_1: |-
settings_guide_displayed_1: |-
documents_guide_add_movie_1: |-
search_guide_1: |-
search_guide_2: |-
getting_started_add_documents_md: |-
```bash
dotnet add package MeiliSearch
```
```csharp
using System.IO;
using System.Text.Json;
using Meilisearch;
using System.Threading.Tasks;
using System.Collections.Generic;
namespace meilisearch_demo
{
public class Movie
{
public string Id { get; set; }
public string Title { get; set; }
public string Poster { get; set; }
public string Overview { get; set; }
public IEnumerable<string> Genres { get; set; }
}
internal class Program
{
static async Task Main(string[] args)
{
MeilisearchClient client = new MeilisearchClient("http://localhost:7700", "masterKey");
var options = new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
};
string jsonString = await File.ReadAllTextAsync("movies.json");
var movies = JsonSerializer.Deserialize<IEnumerable<Movie>>(jsonString, options);
var index = client.Index("movies");
await index.AddDocuments<Movie>(movies);
}
}
}
```
[About this SDK](https://www.github.com/meilisearch/meilisearch-dotnet)
getting_started_search_md: |-
```csharp
MeilisearchClient client = new MeilisearchClient("http://localhost:7700", "masterKey");
var index = client.Index("movies");
SearchResult<Movie> movies = await index.Search<Movie>("harry pottre");
foreach (var movie in movies.Hits)
{
Console.WriteLine(movie.Title);
}
```
[About this SDK](https://www.github.com/meilisearch/meilisearch-dotnet)
faceted_search_update_settings_1: |-
faceted_search_filter_1: |-
SearchQuery filters = new SearchQuery()
{
Filter = new string[][]
{
new string[] {"genres = Horror", "genres = Mystery"},
new string[] {"director = \"Jordan Peele\""}
}
};
SearchResult<Movie> movies = await client.Index("movies").Search<Movie>("thriller", filters);
foreach (var movie in movies.Hits)
{
Console.WriteLine(movie.Title);
}
faceted_search_facets_distribution_1: |-
SearchQuery filters = new SearchQuery()
{
FacetsDistribution = new string[] { "genres" }
};
SearchResult<Movie> movies = await client.Index("movies").Search<Movie>("Batman", filters);
foreach (var movie in movies.Hits)
{
Console.WriteLine(movie.Title);
}
faceted_search_walkthrough_filterable_attributes_1: |-
faceted_search_walkthrough_filter_1: |-
faceted_search_walkthrough_facets_distribution_1: |-
add_movies_json_1: |-
post_dump_1: |-
get_dump_status_1: |-
phrase_search_1: |-
sorting_guide_update_sortable_attributes_1: |-
sorting_guide_update_ranking_rules_1: |-
sorting_guide_sort_parameter_1: |-
sorting_guide_sort_parameter_2: |-
get_sortable_attributes_1: |-
update_sortable_attributes_1: |-
reset_sortable_attributes_1: |-
search_parameter_guide_sort_1: |-
geosearch_guide_filter_settings_1: |-
List<string> attributes = new() { "_geo" };
UpdateStatus result = await client.Index("movies").UpdateFilterableAttributes(attributes);
geosearch_guide_filter_usage_1: |-
SearchQuery filters = new SearchQuery() { Filter = "_geoRadius(45.4628328, 9.1076931, 2000)" };
SearchResult<Restaurant> restaurants = await client.Index("restaurants").Search<Restaurant>("", filters);
foreach (var restaurant in restaurants.Hits)
{
Console.WriteLine(restaurant.Name);
}
geosearch_guide_filter_usage_2: |-
SearchQuery filters = new SearchQuery()
{
Filter = new string[] { "_geoRadius(45.4628328, 9.1076931, 2000) AND type = pizza" }
};
SearchResult<Restaurant> restaurants = await client.Index("restaurants").Search<Restaurant>("restaurants", filters);
foreach (var restaurant in restaurants.Hits)
{
Console.WriteLine(restaurant.Name);
}
geosearch_guide_sort_settings_1: |-
List<string> attributes = new() { "_geo" };
UpdateStatus result = await client.Index("restaurants").UpdateSortableAttributes(attributes);
geosearch_guide_sort_usage_1: |-
SearchQuery filters = new SearchQuery()
{
Sort = new string[] { "_geoPoint(48.8583701,2.2922926):asc" }
};
SearchResult<Restaurant> restaurants = await client.Index("restaurants").Search<Restaurant>("", filters);
foreach (var restaurant in restaurants.Hits)
{
Console.WriteLine(restaurant.Name);
}
geosearch_guide_sort_usage_2: |-
SearchQuery filters = new SearchQuery()
{
Sort = new string[] {
"_geoPoint(48.8583701,2.2922926):asc",
"rating:desc"
}
};
SearchResult<Restaurant> restaurants = await client.Index("restaurants").Search<Restaurant>("restaurants", filters);
foreach (var restaurant in restaurants.Hits)
{
Console.WriteLine(restaurant.Name);
}