Last active
January 10, 2017 19:00
-
-
Save radzserg/635aa1540159524ffde38587b10ac210 to your computer and use it in GitHub Desktop.
An example of building ES query for raw user input.
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
| <?php | |
| if (!empty($filterParams['q'])) { | |
| $query = CMap::mergeArray($query, [ | |
| [ | |
| 'bool' => [ | |
| 'should' => [ | |
| ['match' => ['name' => ['query' => $filterParams['q'], 'boost' => 5]]], | |
| ['match' => ['short_description' => ['query' => $filterParams['q'], 'boost' => 3]]], | |
| ['match' => ['tag_names' => ['query' => $filterParams['q'], 'boost' => 1]]] | |
| ] | |
| ] | |
| ] | |
| ]); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment