Created
May 21, 2017 11:41
-
-
Save vinh0604/cb1887be100a587c7034e017a26c7c67 to your computer and use it in GitHub Desktop.
Medium code sample - Refactoring legacy code base
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // adding region filter to the request | |
| // if region is not provided, considering it as select all | |
| if (regions === null || regions.length === 0) { | |
| request.filter.bool.must.push({ | |
| match: { | |
| region: 'all' | |
| } | |
| }) | |
| } else { | |
| regions.forEach((region) => { | |
| request.filter.bool.must.push({ | |
| match: { | |
| region: region | |
| } | |
| }) | |
| }) | |
| } | |
| // adding price filter to the request | |
| // if min price is not provided, considering it as 0 | |
| // if max price is not provided, considering it as INFINITE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment