@@ 948-966 (lines=19) @@ | ||
945 | foreach ($searchQuery->require as $field => $values) { |
|
946 | $requireq = array(); |
|
947 | ||
948 | foreach ($values as $value) { |
|
949 | if ($value === SearchQuery::$missing) { |
|
950 | $requireq[] = "(*:* -{$field}:[* TO *])"; |
|
951 | } elseif ($value === SearchQuery::$present) { |
|
952 | $requireq[] = "{$field}:[* TO *]"; |
|
953 | } elseif ($value instanceof SearchQuery_Range) { |
|
954 | $start = $value->start; |
|
955 | if ($start === null) { |
|
956 | $start = '*'; |
|
957 | } |
|
958 | $end = $value->end; |
|
959 | if ($end === null) { |
|
960 | $end = '*'; |
|
961 | } |
|
962 | $requireq[] = "$field:[$start TO $end]"; |
|
963 | } else { |
|
964 | $requireq[] = $field.':"'.$value.'"'; |
|
965 | } |
|
966 | } |
|
967 | ||
968 | $fq[] = '+('.implode(' ', $requireq).')'; |
|
969 | } |
|
@@ 989-1007 (lines=19) @@ | ||
986 | $excludeq = []; |
|
987 | $missing = false; |
|
988 | ||
989 | foreach ($values as $value) { |
|
990 | if ($value === SearchQuery::$missing) { |
|
991 | $missing = true; |
|
992 | } elseif ($value === SearchQuery::$present) { |
|
993 | $excludeq[] = "{$field}:[* TO *]"; |
|
994 | } elseif ($value instanceof SearchQuery_Range) { |
|
995 | $start = $value->start; |
|
996 | if ($start === null) { |
|
997 | $start = '*'; |
|
998 | } |
|
999 | $end = $value->end; |
|
1000 | if ($end === null) { |
|
1001 | $end = '*'; |
|
1002 | } |
|
1003 | $excludeq[] = "$field:[$start TO $end]"; |
|
1004 | } else { |
|
1005 | $excludeq[] = $field.':"'.$value.'"'; |
|
1006 | } |
|
1007 | } |
|
1008 | ||
1009 | $fq[] = ($missing ? "+{$field}:[* TO *] " : '') . '-('.implode(' ', $excludeq).')'; |
|
1010 | } |