Comments (4)
I think we should configure engine here
https://github.com/laravel/scout/blob/c145b4dd752ccdda7855344981dd1815ee0ae746/src/Builder.php#L314
from laravel-scout-elasticsearch.
Or you can extend builder in your app to
$model::search($query,
function (Client $client, Search $body) use ($model, $field) {
$highlight = new Highlight();
$highlight->addField($field);
$body->addHighlight($highlight);
return $client->search(['index' => $model->searchableAs(), 'body' => $body->toArray()]);
})->using(new Engine(new HitsIteratorFactory))->paginate(100);
But I'm still not sure what solution is better. Or maybe we should propose to change api
in laravel/scout
from laravel-scout-elasticsearch.
Now perfect api for me looks like(no callback at all)
$model::search(new Query($term))->engine(new Engine(new ResultsFactory))->paginate(100);
Or now we can do like this
$raw = $model::search($query,
function (Client $client, Search $body) use ($model, $field) {
$highlight = new Highlight();
$highlight->addField($field);
$body->addHighlight($highlight);
return $client->search(['index' => $model->searchableAs(), 'body' => $body->toArray()]);
})->raw();
$resullts = new HiglightedResults($raw);
from laravel-scout-elasticsearch.
Or without changing laravel/scout
api
$model::search($term)->query(new ResultsFactory)->paginate(100);
We should't choose how to map results in the engine if we have queryCallback
just send to the callback raw results then ResultsFactory
can map it in the right way
@booni3 Now I'm working on another issue, I'm trying to finish parallel importing so feel free to send PR
if you want.
from laravel-scout-elasticsearch.
Related Issues (20)
- [Feature] v5 with forked handcraftedinthealps/elasticsearch-dsl HOT 8
- [Feature] Change app namespace call in commands HOT 2
- [BUG] Call to a member function toCodeString() on null HOT 5
- [BUG] Bulk update error when saving with boolean HOT 1
- [BUG] NoNodeAvailableException: No alive nodes. All the 1 nodes seem to be down HOT 3
- [BUG] The attribute [routing] either does not exist or was not retrieved for model [App\Models\Track]. HOT 5
- [BUG] Possibly unexpected behaviour, when using additional callback in `search` HOT 3
- [Feature] Utilize custom "options" of a builder HOT 2
- configure stopwords HOT 1
- "current.health":"RED","message":"Cluster health status changed from [YELLOW] to [RED] HOT 1
- [BUG] ProgressBar updates are posted to stderr HOT 1
- [BUG] Class Elasticsearch\Client not found HOT 3
- [Feature] Add possibility to use RangeQuery and other terms instances as value for $scoutQuery->where() HOT 2
- php artisan scout:import error? Cannot use Encore\Admin\Form as Form because the name is already in use on line 21 HOT 10
- [Feature] Use SearchableScope instead PageScope HOT 4
- PHP 8.3 support HOT 2
- is there any way to revert to the previous index state before reindexing ? HOT 3
- Elastic has prefix restrictions on reads HOT 1
- How to use the latest version of this package with Elasticsearch 7? HOT 3
- PHP-Parser not in direct dependencies, PHP-Parser > 5.0 is incompatible HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-scout-elasticsearch.