Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#35762 closed enhancement (fixed)

Search in post excerpt

Reported by: sebastianpisula's profile sebastian.pisula Owned by: boonebgorges's profile boonebgorges
Milestone: 4.5 Priority: normal
Severity: normal Version:
Component: Query Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

I think that search should check post_excerpt field.

Attachments (4)

35762.patch (783 bytes) - added by sebastian.pisula 9 years ago.
35762.diff (1.9 KB) - added by swissspidy 9 years ago.
35762.2.diff (2.4 KB) - added by swissspidy 9 years ago.
35762.3.diff (3.6 KB) - added by swissspidy 9 years ago.

Download all attachments as: .zip

Change History (10)

#1 @swissspidy
9 years ago

  • Component changed from General to Query
  • Keywords has-patch added

#2 @boonebgorges
9 years ago

  • Keywords needs-unit-tests added

@swissspidy
9 years ago

#3 follow-up: @swissspidy
9 years ago

  • Keywords has-unit-tests added; needs-unit-tests removed
  • Milestone changed from Awaiting Review to Future Release

The previous patch was missing an additional $like passed to $wpdb->prepare.

35762.diff adds that, and an accompanying test.

I like the idea of also searching the post excerpt and have implemented this on a couple of sites myself. Perhaps even 4.5 material?

#4 in reply to: ↑ 3 @boonebgorges
9 years ago

  • Keywords needs-patch needs-unit-tests added; has-patch has-unit-tests removed

Replying to swissspidy:

The previous patch was missing an additional $like passed to $wpdb->prepare.

35762.diff adds that, and an accompanying test.

I like the idea of also searching the post excerpt and have implemented this on a couple of sites myself. Perhaps even 4.5 material?

We'll need to add post_excerpt to the orderby logic in WP_Query::parse_search_order(). It could be lumped in with post_content or even, I'd suggest, one step higher in the priority than post_content.

If we get this, we'll slip it into 4.5.

@swissspidy
9 years ago

@swissspidy
9 years ago

#5 @swissspidy
9 years ago

  • Keywords has-patch has-unit-tests added; needs-patch needs-unit-tests removed
  • Milestone changed from Future Release to 4.5

35762.3.diff includes the suggested fixes and additional tests for that.

Post search order is now like this:

  1. post title
  2. post excerpt
  3. post content

#6 @boonebgorges
9 years ago

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

In 36647:

Query: Search should match post_excerpt in addition to title and content.

When ordering search results, exact matches in the post excerpt are weighted
above those in post content, but below those in the post title.

Props swissspidy, sebastian.pisula.
FIxes #35762.

Note: See TracTickets for help on using tickets.