Skip to content
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

Update Filter field #181

Merged
merged 1 commit into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ get_health_1: |-
get_version_1: |-
client.GetVersion()
distinct_attribute_guide_1: |-
client.Index("movies").UpdateDistinctAttribute("product_id")
client.Index("jackets").UpdateDistinctAttribute("product_id")
field_properties_guide_searchable_1: |-
searchableAttributes := []string{
"title",
Expand Down Expand Up @@ -409,4 +409,4 @@ post_dump_1: |-
get_dump_status_1: |-
results, err := client.GetDumpStatus("dump-uid")
phrase_search_1: |-
results, err := client.Index("movies").Search("\"neo\"", &meilisearch.SearchRequest{})
results, err := client.Index("movies").Search("\"african american\" horror", &meilisearch.SearchRequest{})
2 changes: 1 addition & 1 deletion index_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (i Index) Search(query string, request *SearchRequest) (*SearchResponse, er
if request.Matches {
searchPostRequestParams["matches"] = request.Matches
}
if request.Filter != "" {
if request.Filter != nil {
searchPostRequestParams["filter"] = request.Filter
}
if request.Offset != 0 {
Expand Down
56 changes: 56 additions & 0 deletions index_search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,62 @@ func TestIndex_SearchWithFilters(t *testing.T) {
ExhaustiveNbHits: false,
},
},
{
name: "TestIndexSearchWithFilterArray",
args: args{
UID: "indexUID",
client: defaultClient,
query: "and",
filterableAttributes: []string{
"year",
},
request: SearchRequest{
Filter: []string{
"year = 2005",
},
},
},
want: &SearchResponse{
Hits: []interface{}{
map[string]interface{}{
"book_id": float64(4), "title": "Harry Potter and the Half-Blood Prince",
},
},
NbHits: 1,
Offset: 0,
Limit: 20,
ExhaustiveNbHits: false,
},
},
{
name: "TestIndexSearchWithFilterMultipleArray",
args: args{
UID: "indexUID",
client: defaultClient,
query: "and",
filterableAttributes: []string{
"year",
"tag",
},
request: SearchRequest{
Filter: [][]string{
[]string{"year < 1850"},
[]string{"tag = romance"},
},
},
},
want: &SearchResponse{
Hits: []interface{}{
map[string]interface{}{
"book_id": float64(123), "title": "Pride and Prejudice",
},
},
NbHits: 1,
Offset: 0,
Limit: 20,
ExhaustiveNbHits: false,
},
},
{
name: "TestIndexSearchWithMultipleFilter",
args: args{
Expand Down
2 changes: 1 addition & 1 deletion types.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ type SearchRequest struct {
AttributesToCrop []string
CropLength int64
AttributesToHighlight []string
Filter string
Filter interface{}
Matches bool
FacetsDistribution []string
PlaceholderSearch bool
Expand Down
16 changes: 14 additions & 2 deletions types_easyjson.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.