Skip to content

Commit

Permalink
Merge #286
Browse files Browse the repository at this point in the history
286: Changes related to the next Meilisearch release (v0.27.0) r=curquiza a=meili-bot

Related to this issue: meilisearch/integration-guides#190

This PR:
- gathers the changes related to the next Meilisearch release (v0.27.0) so that this package is ready when the official release is out.
- should pass the tests against the [latest pre-release of Meilisearch](https://github.com/meilisearch/meilisearch/releases).
- might eventually contain test failures until the Meilisearch v0.27.0 is out.

⚠️ This PR should NOT be merged until the next release of Meilisearch (v0.27.0) is out.

_This PR is auto-generated for the [pre-release week](https://github.com/meilisearch/integration-guides/blob/master/guides/pre-release-week.md) purpose._

Done:
- #287 
- #289
- #290 
- #291 
- #294
- #293 

# Release
**:warning:** The go package didn't need a version update CI will publish the package once the `Publish release` will be done. However, a version file exists and this is only for analytics but it already is on the next version (the v0.19.1).

This version makes this package compatible with MeiliSearch v0.27.0🎉 
Check out the changelog of [MeiliSearch v0.27.0](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.27.0) for more information about the changes.

## 🚀 Enhancements

* Feature/Analytics (#279) `@brunoocasali`
* Add new methods for the new typo tolerance settings #294 `@alallema`
`Index.GetTypoTolerance()`
`Index.UpdateTypoTolerance(params)`
`Index.ResetTypoTolerance()`
* Ensure nested field support #290 `@alallema`
* Add new search parameters highlightPreTag, highlightPostTag and cropMarker #291 `@alallema`


Co-authored-by: meili-bot <74670311+meili-bot@users.noreply.github.com>
Co-authored-by: Amélie <alallema@users.noreply.github.com>
Co-authored-by: alallema <amelie@meilisearch.com>
  • Loading branch information
4 people committed May 9, 2022
2 parents 44aa5f3 + ec887b0 commit 5ebf404
Show file tree
Hide file tree
Showing 12 changed files with 1,466 additions and 381 deletions.
130 changes: 93 additions & 37 deletions .code-samples.meilisearch.yaml
Expand Up @@ -92,41 +92,48 @@ get_settings_1: |-
update_settings_1: |-
distinctAttribute := "movie_id"
settings := meilisearch.Settings{
RankingRules: []string{
"words",
"typo",
"proximity",
"attribute",
"sort",
"exactness",
"release_date:desc",
"rank:desc",
},
DistinctAttribute: &distinctAttribute,
SearchableAttributes: []string{
"title",
"overview",
"genres",
},
DisplayedAttributes: []string{
"title",
"overview",
"genres",
"release_date",
},
StopWords: []string{
"the",
"a",
"an",
},
SortableAttributes: []string{
"title",
"release_date",
},
Synonyms: map[string][]string{
"wolverine": []string{"xmen", "logan"},
"logan": []string{"wolverine"},
},
RankingRules: []string{
"words",
"typo",
"proximity",
"attribute",
"sort",
"exactness",
"release_date:desc",
"rank:desc",
},
DistinctAttribute: &distinctAttribute,
SearchableAttributes: []string{
"title",
"overview",
"genres",
},
DisplayedAttributes: []string{
"title",
"overview",
"genres",
"release_date",
},
StopWords: []string{
"the",
"a",
"an",
},
SortableAttributes: []string{
"title",
"release_date",
},
Synonyms: map[string][]string{
"wolverine": []string{"xmen", "logan"},
"logan": []string{"wolverine"},
},
TypoTolerance: &meilisearch.TypoTolerance{
MinWordSizeForTypos: meilisearch.MinWordSizeForTypo{
OneTypo: 8,
TwoTypos: 10,
},
DisableOnAttributes: []string{"title"},
},
}
client.Index("movies").UpdateSettings(&settings)
reset_settings_1: |-
Expand Down Expand Up @@ -214,6 +221,18 @@ update_sortable_attributes_1: |-
client.Index("books").UpdateSortableAttributes(&sortableAttributes)
reset_sortable_attributes_1: |-
client.Index("books").ResetSortableAttributes()
get_typo_tolerance_1:
client.Index("books").GetTypoTolerance()
update_typo_tolerance_1: |-
client.Index("books").UpdateTypoTolerance(&meilisearch.TypoTolerance{
MinWordSizeForTypos: meilisearch.MinWordSizeForTypo{
OneTypo: 4,
TwoTypos: 10,
},
DisableOnAttributes: []string{"title"},
})
reset_typo_tolerance_1: |-
client.Index("books").ResetTypoTolerance()
get_index_stats_1: |-
client.Index("movies").GetStats()
get_indexes_stats_1: |-
Expand Down Expand Up @@ -266,14 +285,25 @@ search_parameter_guide_retrieve_1: |-
AttributesToRetrieve: []string{"overview", "title"},
})
search_parameter_guide_crop_1: |-
resp, err := client.Index("movies").Search("shifu" &meilisearch.SearchRequest{
resp, err := client.Index("movies").Search("shifu", &meilisearch.SearchRequest{
AttributesToCrop: []string{"overview"},
CropLength: 10,
CropLength: 5,
})
search_parameter_guide_crop_marker_1: |-
resp, err := client.Index("movies").Search("shifu", &meilisearch.SearchRequest{
AttributesToCrop: []string{"overview"},
CropMarker: "[…]",
})
search_parameter_guide_highlight_1: |-
resp, err := client.Index("movies").Search("winter feast", &meilisearch.SearchRequest{
AttributesToHighlight: []string{"overview"},
})
search_parameter_guide_highlight_tag_1: |-
resp, err := client.Index("movies").Search("winter feast", &meilisearch.SearchRequest{
AttributesToHighlight: []string{"overview"},
HighlightPreTag: "<span class=\"highlight\">",
HighlightPostTag: "</span>",
})
search_parameter_guide_matches_1: |-
resp, err := client.Index("movies").Search("winter feast", &meilisearch.SearchRequest{
Matches: true,
Expand Down Expand Up @@ -342,6 +372,32 @@ settings_guide_sortable_1: |-
},
}
client.Index("books").UpdateSettings(&settings)
settings_guide_typo_tolerance_1: |-
client.index("movies").UpdateTypoTolerance({
MinWordSizeForTypos: meilisearch.MinWordSizeForTypo{
TwoTypos: 12,
},
DisableOnAttributes: []string{"title"},
})
typo_tolerance_guide_1: |-
client.index("movies").UpdateTypoTolerance({
Enabled: false,
})
typo_tolerance_guide_2: |-
client.index("movies").UpdateTypoTolerance({
DisableOnAttributes: []string{"title"},
})
typo_tolerance_guide_3: |-
client.index("movies").UpdateTypoTolerance({
DisableOnWords: []string{"shrek"},
})
typo_tolerance_guide_4: |-
client.index("movies").UpdateTypoTolerance({
MinWordSizeForTypos: meilisearch.MinWordSizeForTypo{
OneTypo: 4,
TwoTypos: 10,
},
})
add_movies_json_1: |-
import (
"encoding/json"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-release-tests.yml
Expand Up @@ -40,6 +40,6 @@ jobs:
- name: Get the latest Meilisearch RC
run: echo "MEILISEARCH_VERSION=$(curl https://raw.githubusercontent.com/meilisearch/integration-guides/main/scripts/get-latest-meilisearch-rc.sh | bash)" >> $GITHUB_ENV
- name: Meilisearch (${{ env.MEILISEARCH_VERSION }}) setup with Docker
run: docker run -d -p 7700:7700 getmeili/meilisearch:${{ env.MEILISEARCH_VERSION }} ./meilisearch --master-key=masterKey --no-analytics
run: docker run -d -p 7700:7700 getmeili/meilisearch:${{ env.MEILISEARCH_VERSION }} meilisearch --master-key=masterKey --no-analytics
- name: Run integration tests
run: go test -v ./...
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Expand Up @@ -57,6 +57,6 @@ jobs:
dep ensure
fi
- name: Meilisearch setup (latest version) with Docker
run: docker run -d -p 7700:7700 getmeili/meilisearch:latest ./meilisearch --master-key=masterKey --no-analytics
run: docker run -d -p 7700:7700 getmeili/meilisearch:latest meilisearch --master-key=masterKey --no-analytics
- name: Run integration tests
run: go test -v ./...
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -227,7 +227,7 @@ searchRes, err := index.Search("wonder",

## 🤖 Compatibility with Meilisearch

This package only guarantees the compatibility with the [version v0.26.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v0.26.0).
This package only guarantees the compatibility with the [version v0.27.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v0.27.0).

## 💡 Learn More

Expand Down
9 changes: 9 additions & 0 deletions index_search.go
Expand Up @@ -38,6 +38,15 @@ func (i Index) Search(query string, request *SearchRequest) (*SearchResponse, er
if request.CropLength != 0 {
searchPostRequestParams["cropLength"] = request.CropLength
}
if request.CropMarker != "" {
searchPostRequestParams["cropMarker"] = request.CropMarker
}
if request.HighlightPreTag != "" {
searchPostRequestParams["highlightPreTag"] = request.HighlightPreTag
}
if request.HighlightPostTag != "" {
searchPostRequestParams["highlightPostTag"] = request.HighlightPostTag
}
if len(request.AttributesToRetrieve) != 0 {
searchPostRequestParams["attributesToRetrieve"] = request.AttributesToRetrieve
}
Expand Down

0 comments on commit 5ebf404

Please sign in to comment.