Skip to content

Conversation

@alallema
Copy link
Contributor

As per meilisearch/meilisearch#2214 new search parameters are introduced:

  • highlightPreTag
  • highlightPostTag
  • cropMarker

Co-authored-by: cvermand <[email protected]>
@alallema alallema requested a review from bidoubiwa April 27, 2022 14:05
@alallema alallema added the enhancement New feature or request label May 2, 2022
if request.CropLength != 0 {
searchPostRequestParams["cropLength"] = request.CropLength
}
if request.CropMarker != "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This CropMarker can be null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I declare it as string and not as *string. In go if you create a struct all fields exist. This is why I check it.
I had thought to create every field as * so that when instantiating the structure they would be set to nil.
But it would have been much less convenient for the declaration so I preferred to make it easier for the user.

if request.CropMarker != "" {
searchPostRequestParams["cropMarker"] = request.CropMarker
}
if request.HighlightPreTag != "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a way to automate this kind of thing, like serialize somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love it! I didn't find any other ways

Hits: []interface{}{
map[string]interface{}{
"book_id": float64(1), "title": "Alice In Wonderland",
"book_id": float64(123), "title": "Pride and Prejudice",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give some idea about this float64(...)? Why do you need to convert it to float?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the default behavior of the deserializer in golang you can read in the documentation

To unmarshal JSON into an interface value, Unmarshal stores one of these in the interface value:
bool, for JSON booleans
float64, for JSON numbers
string, for JSON strings
[]interface{}, for JSON arrays
map[string]interface{}, for JSON objects
nil for JSON null

And by default, every number declare are int so in:

	map[string]interface{}{
		"book_id": 1,
	}

book_id will be an int that is why I convert it. I didn't find a better way to do it.

@alallema alallema requested a review from brunoocasali May 2, 2022 15:33
Copy link
Member

@brunoocasali brunoocasali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! (go tests are a little bit harder to read for me yet, but I think they are ok) 👯‍♂️

@alallema
Copy link
Contributor Author

alallema commented May 3, 2022

bors merge

bors bot added a commit that referenced this pull request May 3, 2022
291: Add new search parameters highlightPreTag, highlightPostTag and cropMarker r=alallema a=alallema

As per meilisearch/meilisearch#2214 new search parameters are introduced: 

- `highlightPreTag`
- `highlightPostTag`
- `cropMarker`


Co-authored-by: alallema <[email protected]>
Co-authored-by: Amélie <[email protected]>
@bors
Copy link
Contributor

bors bot commented May 3, 2022

Build failed:

@alallema alallema merged commit 25fbcdf into bump-meilisearch-v0.27.0 May 3, 2022
@alallema alallema deleted the cropping_highlighting branch May 3, 2022 08:30
bors bot added a commit that referenced this pull request May 9, 2022
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 <[email protected]>
Co-authored-by: Amélie <[email protected]>
Co-authored-by: alallema <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants