Comments (6)
Is it necessary that every searchable object also has to support count? Like this every time I use searchable for an object, I also have to implement count.
Refactoring/enhancing of the function is a good idea. It's probably Elastica_Type::count(Elastica_Query_Abstract $query = null)
If the query is not set, a match all query should be created.
from elastica.
"Is it necessary that every searchable object also has to support count?"
Well as elasticsearch provides count each time search is available, I'd say yes...
We can also keep these features separated by adding a Countable
interface, but I feel it makes less sense, especially when you want to paginate search results: the count is needed as much as the search.
Elasticsearch keeps count
and search
very similar and I think Elastica should reflect this consistency. By giving both methods the same signature, ($query)
.
So, move the query construction logic to a new protected method to avoid code duplication.
Thoughts?
from elastica.
I somehow like the idea of splitting up searchable and countable, as I did not use count yet and would like to keep it separate. But it is also ok for me to "merge" it at the moment. Interesting is that PHP also has a countable interface (without parameters): http://php.net/manual/en/class.countable.php
To be honest, I do not like my implementation of the query processing inside the search function, especially because the same processing has to be done for every search function. I already thought about introducing a search object that would be passed to the search function. But I'm not sure if this would make everything more complicated because I like to just pass a string to the search function. Or the other option could be to use the search/count object inside the search function. But I have to think more about this first.
So I think at the moment it's best to move it to a protected method.
from elastica.
There is indeed a minor flaw in the architecture. The searchable classes are given too much responsibilities. An easy way to reduce the code duplication between searchable classes is to move the query construction to a static method Elastica_Query::create
. That's what I am doing now.
from elastica.
-> #13
from elastica.
Good idea. I do not really like that we have to use a static function for this one, but at the moment it looks like the best solution.
from elastica.
Related Issues (20)
- the sort search is incorrect, I need help
- Undefined method Elastica\Query\MultiMatch::setStoredFields() in Elastica v7.3.0 HOT 1
- Token based authentication HOT 2
- No way to disable SSL verification HOT 1
- When will ElasticSearch 8.x compatibility be released? HOT 1
- Support for runtime_mapping HOT 6
- Support querying with SQL HOT 1
- Couldn't connect to host, Elasticsearch down? HOT 3
- Upgrade Elasticsearch to 7.10.2 from 6.x HOT 1
- Does RetryOnConflict suppose to work with Bulk updates HOT 6
- Getting Elastic 8.x to GA HOT 9
- Can't get elastic response when disabling proxy but works in command line HOT 2
- Support the Combined Fields query type HOT 1
- Psalm error caused by duplicate line HOT 4
- PHP 8.3 support please HOT 4
- Hi addType() not available
- Is it possible to add raw query with array?
- Is it possible to bulk update documents with all 3 types in same request (create, update, delete) ?
- Add optional `routing` parameter to `GeoShapePreIndexed` HOT 1
- BC Break from 7.3.1 to 7.3.2 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 elastica.