Created
April 16, 2015 11:54
-
-
Save freshjones/5378ea75609e3fc9cc8a to your computer and use it in GitHub Desktop.
query override for search api solr direct parse to combine single and multi parsing options
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
| $query = $call_args['query']; | |
| if(!strlen($query)) return; | |
| $q = strtolower($query); | |
| $qArray = explode(" ", trim($q, ' "') ); | |
| $segments = array(); | |
| $count = 0; | |
| foreach($qArray AS $key => $value) | |
| { | |
| if($value != 'and') | |
| { | |
| $segments[$count][] = $value; | |
| } else { | |
| $count++; | |
| } | |
| } | |
| if(!empty($segments)) | |
| { | |
| $qSegements = array(); | |
| foreach($segments AS $key => $values) | |
| { | |
| $qSegements[] = '"' . implode(' ', $values) . '"'; | |
| } | |
| if (!empty($qSegements)) | |
| { | |
| $qString = implode(' AND ', $qSegements); | |
| } | |
| } | |
| $call_args['query'] = isset($qString) ? $qString : $query; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment