Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#17152 closed defect (bug) (fixed)

Multiple keyword search: unnecessary sentence search

Reported by: scribu's profile scribu Owned by: ryan's profile ryan
Milestone: 3.2 Priority: normal
Severity: normal Version:
Component: Performance Keywords: has-patch needs-testing
Focuses: Cc:

Description

's=foo+bar' generates this query:

SELECT SQL_CALC_FOUND_ROWS wp_posts . *
FROM wp_posts
WHERE 1 =1
AND (
	((wp_posts.post_title LIKE '%foo%') OR (wp_posts.post_content LIKE '%foo%'))
	AND
	((wp_posts.post_title LIKE '%bar%') OR (wp_posts.post_content LIKE '%bar%'))
	OR
	(wp_posts.post_title LIKE '%foo bar%')
	OR
	(wp_posts.post_content LIKE '%foo bar%')
)
AND wp_posts.post_type IN ('post', 'page', 'attachment')
AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private')
ORDER BY wp_posts.post_date DESC
LIMIT 0 , 10

Unless I'm missing something, this part is superfluous:

	OR
	(wp_posts.post_title LIKE '%foo bar%')
	OR
	(wp_posts.post_content LIKE '%foo bar%')

Attachments (1)

17152.diff (714 bytes) - added by scribu 14 years ago.

Download all attachments as: .zip

Change History (4)

@scribu
14 years ago

#1 @scribu
14 years ago

  • Keywords has-patch needs-testing added

$q['sentence'] is taken care of above.

Last edited 14 years ago by scribu (previous) (diff)

#2 @blepoxp
14 years ago

Offset by 24 lines but applied cleanly and didn't break functionality. Looks good.

#3 @ryan
14 years ago

  • Owner set to ryan
  • Resolution set to fixed
  • Status changed from new to closed

In [18056]:

Remove duplicate sentence search terms. Props scribu. fixes #17152

Note: See TracTickets for help on using tickets.