Comments (8)
same here, I do want to port some custom sollution to Scount.
what I want now, is sort like this:
'sort' => [
[
'created_at' => [
'order' => 'desc',
],
'id' => [
'order' => 'desc',
],
],
],
is there any option to achieve this at the moment?
from laravel-scout-elastic.
It's a bit tricky passing parameters to the engine, because one has to adhere to the Scout engine base class. I have made some changes to the query and filtering, which I think has made the search return better results, and faster. But nothing on sorting, yet...
from laravel-scout-elastic.
@huglester You could just fork it and make your own special implementation of course.
from laravel-scout-elastic.
@ErickTamayo Hey, I've forked and made some changes to the search query which I think returns much better results, faster.
- Remove asterisk wildcards from beginning and end of query, they make the search slower and make it impossible to use certain boolean operators.
In order to prevent extremely slow wildcard queries, a wildcard term should not start with one of the wildcards * or ?.
-
Use default operator
AND
instead ofOR
, this returns more relevant results (I think) and is closer to what Algolia returns. -
Apply Scout filters as
filter
instead ofmust
. This makes it faster and does not change the scoring of the query search results. I've also changed the filter condition frommatch_phrase
toterm
, which is again faster.
When used in filtering context, the query is said to be a "non-scoring" or "filtering" query. That is, the query simply asks the question: "Does this document match?". The answer is always a simple, binary yes|no.
I've also added a filter to remove results which is not present in the instances of the given model, like the Algolia engine has. That solved issue #36.
Now... The changes I have made to the query will produce different search results, which may produce unwanted results for some. But I think it's a better way of searching. Will you be accepting a PR?
Update 13.feb: I've made the search method configurable in the scout config, and overridable within search searchable model.
from laravel-scout-elastic.
Let's hope we will be able to solve this issue ar 'ELasticsearch' level.
It seems that this driver will be kinda out of sync with algolia - but anyway - this ELasticsearch is other world.
from laravel-scout-elastic.
I have added the ability to define different search types in the config file, or override them like this:
$articles = Article::elasticSearch('multi_match', $q, [
'fields' => ['title', 'content', 'tags'],
'fuzziness' => 'auto',
'prefix_length' => 2,
'operator' => 'AND'
])
->where('is_published', true)
->get();
Using a ElasticSearchable trait, instead of Searchable
.
from laravel-scout-elastic.
Wow. As for now I think this is exactly what is needed!
SO it does support this 'fluent' syntax like: where('is_published', true)?
this is awesome.
from laravel-scout-elastic.
@huglester The where
method is just the filter, as is implemented in the driver today. The "fluent" part is the Elasticsearch field name, the Article
model has a boolean field called is_published
. Very readable :)
I'm planning to submit a PR after I've done some more testing.
from laravel-scout-elastic.
Related Issues (20)
- lumen8 use paginate error, HOT 3
- How to perform advanced customisation? HOT 1
- Warning about type deprecation HOT 10
- All data doesn't get indexed and no error pops up when importing HOT 1
- index not found exception HOT 3
- When i fetch data from elastic its give error like this "no handler found for uri" HOT 1
- Laravel Scout 9. please? HOT 1
- Please add php 8 suport HOT 1
- Make it work with ES 7 HOT 3
- Make it work with ES 7 HOT 1
- ElasticClient namespace incompatible HOT 6
- Change namespace HOT 1
- _ide_helper.php should not be part of the packet HOT 1
- 小建议 HOT 1
- laravel9安装失败了 HOT 1
- '_index' => $model->searchableAs(), '_type' => get_class($model), HOT 1
- Class "ScoutEngines\Elasticsearch\ElasticsearchProvider" not found - Laravel 9 HOT 1
- ->forceDelete() on Model, don't delete on elasticsearch
- Please install the Elasticsearch PHP client: elasticsearch/elasticsearch but is installed HOT 1
- after 7.0 ,only 'index', delete 'Type'
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-elastic.