Skip to content

Commit c443ae2

Browse files
authored
Merge branch 'main' into create-snapshot-501
2 parents 858216c + 1dadb40 commit c443ae2

File tree

10 files changed

+399
-19
lines changed

10 files changed

+399
-19
lines changed

.code-samples.meilisearch.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,3 +797,16 @@ reset_dictionary_1: |-
797797
await client.Index("books").ResetDictionaryAsync();
798798
create_snapshot_1: |-
799799
await client.CreateSnapshotAsync();
800+
facet_search_1: |-
801+
var query = new SearchFacetsQuery()
802+
{
803+
FacetQuery = "fiction",
804+
Filter = "rating > 3"
805+
};
806+
await client.Index("books").FacetSearchAsync("genres", query);
807+
facet_search_3: |-
808+
var query = new SearchFacetsQuery()
809+
{
810+
FacetQuery = "c"
811+
};
812+
await client.Index("books").FacetSearchAsync("genres", query);

README.md

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
## Table of Contents <!-- omit in TOC -->
3131

3232
- [📖 Documentation](#-documentation)
33-
- [⚡ Supercharge your Meilisearch experience](#-supercharge-your-meilisearch-experience)
3433
- [🔧 Installation](#-installation)
3534
- [🚀 Getting started](#-getting-started)
3635
- [🤖 Compatibility with Meilisearch](#-compatibility-with-meilisearch)
@@ -49,10 +48,6 @@ This readme contains all the documentation you need to start using this Meilisea
4948
For general information on how to use Meilisearch—such as our API reference, tutorials, guides, and in-depth articles—refer to our [main documentation website](https://www.meilisearch.com/docs/).
5049

5150

52-
## ⚡ Supercharge your Meilisearch experience
53-
54-
Say goodbye to server deployment and manual updates with [Meilisearch Cloud](https://www.meilisearch.com/cloud?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-dotnet). Get started with a 14-day free trial! No credit card required.
55-
5651
## 🔧 Installation
5752

5853
This package targets .NET Standard 2.1.
@@ -71,18 +66,9 @@ Install-Package MeiliSearch
7166

7267
### Run Meilisearch <!-- omit in toc -->
7368

74-
There are many easy ways to [download and run a Meilisearch instance](https://www.meilisearch.com/docs/learn/getting_started/installation).
75-
76-
For example, using the `curl` command in [your Terminal](https://itconnect.uw.edu/learn/workshops/online-tutorials/web-publishing/what-is-a-terminal/):
77-
78-
```bash
79-
# Install Meilisearch
80-
curl -L https://install.meilisearch.com | sh
81-
# Launch Meilisearch
82-
./meilisearch --master-key=masterKey
83-
```
69+
⚡️ **Launch, scale, and streamline in minutes with Meilisearch Cloud**—no maintenance, no commitment, cancel anytime. [Try it free now](https://cloud.meilisearch.com/login?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-dotnet).
8470

85-
NB: you can also download Meilisearch from **Homebrew** or **APT** or even run it using **Docker**.
71+
🪨 Prefer to self-host? [Download and deploy](https://www.meilisearch.com/docs/learn/self_hosted/getting_started_with_self_hosted_meilisearch?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-dotnet) our fast, open-source search engine on your own infrastructure.
8672

8773
## 🚀 Getting started
8874

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System.Collections.Generic;
2+
using System.Text.Json.Serialization;
3+
4+
namespace Meilisearch
5+
{
6+
/// <summary>
7+
/// Wrapper for facet search query
8+
/// </summary>
9+
public class FacetSearchQuery
10+
{
11+
/// <summary>
12+
/// Gets or sets the facetName property
13+
/// </summary>
14+
[JsonPropertyName("facetName")]
15+
public string FacetName { get; set; }
16+
17+
/// <summary>
18+
/// Gets or sets the facetQuery property
19+
/// </summary>
20+
[JsonPropertyName("facetQuery")]
21+
public string FacetQuery { get; set; }
22+
23+
/// <summary>
24+
/// Gets or sets the q property
25+
/// </summary>
26+
[JsonPropertyName("q")]
27+
public string Query { get; set; }
28+
29+
/// <summary>
30+
/// Gets or sets the filter property
31+
/// </summary>
32+
[JsonPropertyName("filter")]
33+
public dynamic Filter { get; set; }
34+
35+
/// <summary>
36+
/// Gets or sets the matchingStrategy property, can be <c>last</c>, <c>all</c> or <c>frequency</c>.
37+
/// </summary>
38+
[JsonPropertyName("matchingStrategy")]
39+
public string MatchingStrategy { get; set; }
40+
41+
/// <summary>
42+
/// Gets or sets the attributesToSearchOn property
43+
/// </summary>
44+
[JsonPropertyName("attributesToSearchOn")]
45+
public IEnumerable<string> AttributesToSearchOn { get; set; }
46+
}
47+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System.Collections.Generic;
2+
using System.Text.Json.Serialization;
3+
4+
namespace Meilisearch
5+
{
6+
/// <summary>
7+
/// Wrapper for FacetSearchResponse
8+
/// </summary>
9+
public class FacetSearchResult
10+
{
11+
/// <summary>
12+
/// Gets or sets the facetHits property
13+
/// </summary>
14+
[JsonPropertyName("facetHits")]
15+
public IEnumerable<FacetHit> FacetHits { get; set; }
16+
17+
/// <summary>
18+
/// Gets or sets the facet query
19+
/// </summary>
20+
[JsonPropertyName("facetQuery")]
21+
public string FacetQuery { get; set; }
22+
23+
/// <summary>
24+
/// Gets or sets the processingTimeMs property
25+
/// </summary>
26+
[JsonPropertyName("processingTimeMs")]
27+
public int ProcessingTimeMs { get; set; }
28+
29+
/// <summary>
30+
/// Wrapper for Facet Hit
31+
/// </summary>
32+
public class FacetHit
33+
{
34+
/// <summary>
35+
/// Gets or sets the value property
36+
/// </summary>
37+
[JsonPropertyName("value")]
38+
public string Value { get; set; }
39+
40+
/// <summary>
41+
/// Gets or sets the count property
42+
/// </summary>
43+
[JsonPropertyName("count")]
44+
public int Count { get; set; }
45+
}
46+
}
47+
}

src/Meilisearch/Index.Documents.cs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System;
21
using System.Collections.Generic;
32
using System.Linq;
43
using System.Net.Http;
@@ -543,5 +542,35 @@ public async Task<ISearchable<T>> SearchAsync<T>(string query,
543542
.ReadFromJsonAsync<ISearchable<T>>(cancellationToken: cancellationToken)
544543
.ConfigureAwait(false);
545544
}
545+
546+
/// <summary>
547+
/// Search index facets
548+
/// </summary>
549+
/// <param name="facetName">Name of the facet to search.</param>
550+
/// <param name="query">The search criteria to find the facet matches.</param>
551+
/// <param name="cancellationToken">The cancellation token for this call.</param>
552+
/// <returns>Facets meeting the search criteria.</returns>
553+
public async Task<FacetSearchResult> FacetSearchAsync(string facetName,
554+
FacetSearchQuery query = default, CancellationToken cancellationToken = default)
555+
{
556+
FacetSearchQuery body;
557+
if (query == null)
558+
{
559+
body = new FacetSearchQuery() { FacetName = facetName };
560+
}
561+
else
562+
{
563+
body = query;
564+
body.FacetName = facetName;
565+
}
566+
567+
var responseMessage = await _http.PostAsJsonAsync($"indexes/{Uid}/facet-search", body,
568+
Constants.JsonSerializerOptionsRemoveNulls, cancellationToken: cancellationToken)
569+
.ConfigureAwait(false);
570+
571+
return await responseMessage.Content
572+
.ReadFromJsonAsync<FacetSearchResult>(cancellationToken: cancellationToken)
573+
.ConfigureAwait(false);
574+
}
546575
}
547576
}

src/Meilisearch/SearchQuery.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,6 @@ public class SearchQuery
147147
/// Gets or sets rankingScoreThreshold, a number between 0.0 and 1.0.
148148
/// </summary>
149149
[JsonPropertyName("rankingScoreThreshold")]
150-
public decimal RankingScoreThreshold { get; set; }
150+
public decimal? RankingScoreThreshold { get; set; }
151151
}
152152
}

0 commit comments

Comments
 (0)