Closed tonydspaniard closed 10 years ago
That interesting for ES cos filter can be used in more ways than that depending on exactly how you wish to filter, I mean personally in my ES querying it is situated within a filtered property that has a query and filter property within it all topped off with being put in a normal query object but it c an be situated in different places depending upon the type of query you wanna do.
From basic looking I am unsure if filter() in the ES Query actually works in all situations.
Renamed ES method to applyFilter
Using filter
in method names isn't good since it conflicts with existing Elasticsearch term.
Alternatives:
narrow
shrink
refine
where<not-strict>
None of the alternatives is good. We should rename ES because Query::filter()
is much more commonly used than ES filter.
We may consider filterPart
and queryPart
for ES.
Currently in order to make a search function (not following
gii
approach) a user needs to do the following:Or using the
gii
approach (creating anaddCondition
method) it is always required to search for empty orNULL
values. Which even I think is good for demo purposes to have theaddCondition
on the search model reproduced bygii
, I find it quite of non-sense to have the same method on each search model.Failing to not check against
NULL
values will cause two different results on both scenarios. On the first onelike
, it throws an error:Whereas on the second one will produce the following SQL:
SELECT * FROM tbl_contact WHERE full_name IS NULL LIMIT 10
Which IMHO I think is the wrong behavior, even if the
adCondition
function of the search model strictly checks for empty strings notNULL
attributes._Suggestion_
I believe that everybody should be able to use the following:
And
NULL
or empty values should be removed from the resultingQuery
object as it used to happen withCDbCriteria
on Yii1. That will make our search classes cleaner and without the need to check whether I haveNULL
or empty values on my queries and also we will follow an approach that was commonly used by new users.I do not think we should force the
IS NULL
search if an attribute hasnull
value. For that purposes we already haveyii\db\Expression
don't you agree? I think it makes more sense and is less error prone (in terms of search results).