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

EloquentHitsIteratorAggregate trait for properties. #281

Merged
merged 6 commits into from
Jun 19, 2024

Conversation

DavisPuciriuss
Copy link

Added a trait, that sets _score and highlight from EloquentHitsIteratorAggregate.
After adding the trait to your model, you can access '_score' and 'highlight' after a search was performed via 'getElasticsearchScore' and 'getElasticsearchHighlight' functions.

Any feedback appreciated.

…light out of EloquentHitsIteratorAggregate without implementing your own class.
@DavisPuciriuss DavisPuciriuss changed the base branch from master to 8.x June 17, 2024 13:05
Davis Puciriuss added 2 commits June 17, 2024 16:06
@codecov-commenter
Copy link

codecov-commenter commented Jun 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (8.x@304ff4a). Learn more about missing BASE report.

Additional details and impacted files
@@          Coverage Diff           @@
##             8.x     #281   +/-   ##
======================================
  Coverage       ?   98.16%           
  Complexity     ?      266           
======================================
  Files          ?       41           
  Lines          ?      816           
  Branches       ?        0           
======================================
  Hits           ?      801           
  Misses         ?       15           
  Partials       ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

/** @var Model&Searchable&ElasticParams $model */
$model = $models[$key];

if (isset($hit['_score']) && ! empty($hit['_score']) && method_exists($model, 'setElasticsearchScore')) {
Copy link
Owner

Choose a reason for hiding this comment

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

I would prefer that we would call method_exists once for each model type. Not a blocker just possible improvement

@matchish
Copy link
Owner

On comment with possible improvement(up to you)
And plz update README.md and CHANGELOG.md
https://github.com/matchish/laravel-scout-elasticsearch?tab=readme-ov-file#working-with-results

@DavisPuciriuss
Copy link
Author

Updated README.md and CHANGELOG.md to include this change.

CHANGELOG.md Outdated
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/)
### Added
- fromScope, uses forPageAfterId.
- a new option "--parallel" for ImportCommand, can only be used with [Trackable-Jobs](https://github.com/mateusjunges/trackable-jobs-for-laravel) package currently.
- ElasticParams trait, that adds 'getElasticsearchScore' and 'getElasticsearchHighlight' to the model after performing a search.
Copy link
Owner

Choose a reason for hiding this comment

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

it should be a new version
8.0.0-alpha.2

or if you want to have it in stable, you should to create a PR on top of master branch

then it will be 7.7.0

Copy link
Author

Choose a reason for hiding this comment

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

Updated Changelog.md

@matchish matchish merged commit 99ce1c6 into matchish:8.x Jun 19, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants