#2530: Search doesn't work on custom fields
---------------------------------+------------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: jonas
Type: defect | Status: new
Priority: normal | Milestone:
Component: search system | Version: 0.9.5
Severity: normal | Resolution:
Keywords: custom field search |
---------------------------------+------------------------------------------
Comment (by anonymous):
We ran into the same problem on our instance. Unfortunately, it's a shared
install with two instances running. The following code allows them both to
search all custom fields for each particular instance without having to
re-modify it in the future.
'''excerpt from .../trac/ticket/api.py'''
{{{
...
sql, args = query_to_sql(db, query, 'b.newvalue')
sql2, args2 = query_to_sql(db, query,
'summary||keywords||description||reporter||cc')
sql3, args3 = query_to_sql(db, query, 'c.value')
cursor = db.cursor()
cursor.execute("SELECT DISTINCT
a.summary,a.description,a.reporter, "
"a.keywords,a.id,a.time FROM ticket a "
"LEFT JOIN ticket_change b ON a.id = b.ticket "
"LEFT OUTER JOIN ticket_custom c ON (a.id =
c.ticket)"
"WHERE (b.field='comment' AND %s ) OR %s OR %s" %
(sql,
sql2, sql3),
args + args2 + args3)
for summary,desc,author,keywords,tid,date,ltc in cursor:
...
}}}
This works only when you want to search across '''all''' custom fields.
--
Ticket URL: <http://projects.edgewall.com/trac/ticket/2530>
The Trac Project <http://trac.edgewall.com/>
_______________________________________________
Trac-Tickets mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac-tickets