Add or operator for Elasticsearch filters and use exists if value is null
#3960
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related issues
I needed a possibility to simply add an
or/shouldfilter to thequickSearchByQuerymethod.This wasn't possible yet, so I extended the
prepareElasticsearchQueryBodymethod of the ElasticSearch search-adapter to accept anoroperator in the value property.I also added an ES
existsfilter if the value isnullif you just wan't the field to benull.Short description and why it's useful
I had to make a product query where I wanted a collection of products with a specific value or an empty one. This wasn't possible yet because all filters are chained as 'AND' filters.
Now you can make query like this (
orin the last two lines) to show all products withcustom_attributeis2or3orcustom_attributeis just empty (null):In our use-case the products have clusters, so I wan't to show products to the customer which have his current cluster OR if there are not enough of them just regular products without a cluster.
With this changes I can make queries like this to the ES while I still can use all the advantages of
quickSearchByQuery:If you think it isn't an essential functionallity, just ignore and close this PR.
But I thought this might come in handy.
Which environment this relates to
Check your case. In case of any doubts please read about Release Cycle
developbranch and want to merge it back todevelopreleasebranch and want to merge it back toreleasehotfixormasterbranch and want to merge it back tohotfixUpgrade Notes and Changelog
IMPORTANT NOTICE - Remember to update
CHANGELOG.mdwith description of your changeContribution and currently important rules acceptance