Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
osticket
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
docker
osticket
Commits
c9c08bf6
Commit
c9c08bf6
authored
10 years ago
by
Jared Hancock
Browse files
Options
Downloads
Patches
Plain Diff
search: Use backend for non keyword-based queries
parent
f342c60a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/class.search.php
+20
-9
20 additions, 9 deletions
include/class.search.php
with
20 additions
and
9 deletions
include/class.search.php
+
20
−
9
View file @
c9c08bf6
...
...
@@ -62,6 +62,7 @@ class SearchInterface {
}
function
find
(
$query
,
$criteria
,
$model
=
false
,
$sort
=
array
())
{
$query
=
Format
::
searchable
(
$query
);
return
$this
->
backend
->
find
(
$query
,
$criteria
,
$model
,
$sort
);
}
...
...
@@ -107,6 +108,7 @@ class SearchInterface {
$new
,
array
(
'title'
=>
Format
::
searchable
(
$model
->
getSubject
()),
'number'
=>
$model
->
getNumber
(),
'status'
=>
$model
->
getStatus
(),
'topic_id'
=>
$model
->
getTopicId
(),
'priority_id'
=>
$model
->
getPriorityId
(),
...
...
@@ -196,7 +198,7 @@ class SearchInterface {
// Users, organizations
Signal
::
connect
(
'model.created'
,
array
(
$this
,
'createModel'
));
Signal
::
connect
(
'model.updated'
,
array
(
$this
,
'updateModel'
));
Signal
::
connect
(
'model.deleted'
,
array
(
$this
,
'deleteModel'
));
#
Signal::connect('model.deleted', array($this, 'deleteModel'));
}
}
...
...
@@ -221,6 +223,7 @@ class MysqlSearchBackend extends SearchBackend {
$type
=
'H'
;
break
;
case
$model
instanceof
Ticket
:
$attrs
[
'title'
]
=
$attrs
[
'number'
]
.
' '
.
$attrs
[
'title'
];
$type
=
'T'
;
break
;
case
$model
instanceof
User
:
...
...
@@ -263,16 +266,22 @@ class MysqlSearchBackend extends SearchBackend {
$search
=
'MATCH (search.title, search.content) AGAINST ('
.
db_input
(
$query
)
.
$mode
.
')'
;
$tables
=
array
(
"(
SELECT object_type, object_id,
$search
AS `relevance`
FROM `ost__search` `search`
WHERE
$search
) `search`"
);
$tables
=
array
();
$P
=
TABLE_PREFIX
;
$sort
=
''
;
if
(
$query
)
{
$tables
[]
=
"(
SELECT object_type, object_id,
$search
AS `relevance`
FROM `
{
$P
}
_search` `search`
WHERE
$search
) `search`"
;
$sort
=
'ORDER BY `search`.`relevance`'
;
}
switch
(
$model
)
{
case
false
:
case
'Ticket'
:
$P
=
TABLE_PREFIX
;
$tables
[]
=
"(select ticket_id as ticket_id from
{
$P
}
ticket
) B1 ON (B1.ticket_id = search.object_id and search.object_type = 'T')"
;
$tables
[]
=
"(select A2.id as thread_id, A1.ticket_id from
{
$P
}
ticket A1
...
...
@@ -298,6 +307,7 @@ class MysqlSearchBackend extends SearchBackend {
case
'user_id'
:
case
'isanswered'
:
case
'isoverdue'
:
case
'number'
:
$where
[]
=
sprintf
(
'A1.%s = %s'
,
$name
,
db_input
(
$value
));
break
;
case
'created__gte'
:
...
...
@@ -341,13 +351,14 @@ class MysqlSearchBackend extends SearchBackend {
$where
[]
=
'('
.
implode
(
' OR '
,
$access
)
.
')'
;
// TODO: Consider sorting preferences
$sql
=
'SELECT DISTINCT '
.
$key
.
' FROM '
.
implode
(
' LEFT JOIN '
,
$tables
)
.
' WHERE '
.
implode
(
' AND '
,
$where
)
// TODO: Consider sorting preferences
.
' ORDER BY `relevance` DESC'
.
$sort
.
' LIMIT 500'
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment