statamic / v2-hub

Statamic 2 - Feature Requests and Bug Reports
https://statamic.com
95 stars 5 forks source link

FR: Weighted fields with local search driver #2449

Open medvesekg opened 4 years ago

medvesekg commented 4 years ago

Describe the solution you'd like I would like to be able to define custom weights for different searchable fields when using the local search driver. The use case would be that I would want to have items that have the search term in the title to appear near the top of the search results.

Additional context I would like to to this in search.yaml

driver: local
searchable:
  - title
  - content
weights:
  - title: 50
  - content: 10
simonhamp commented 4 years ago

Why not just...?

searchable:
  -
    field: title
    weight: 50
  -
    field: content
    weight: 10
  - author

This keeps the shorthand syntax concise and follows the pattern used elsewhere (e.g. routes.yaml) that allows you to expand out the array when necessary.