Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When searching in an assets container, changing the order of results doesn't work #10795

Closed
mattmultiplied opened this issue Sep 12, 2024 · 4 comments
Labels

Comments

@mattmultiplied
Copy link

Bug description

When you search for an asset, the ordering filters "Size" and "Last Modified" stop working.

I have only tested this using an S3 container, with a search index on the container.

How to reproduce

Set-up an S3 container with assets in, search for an asset and attempt to re-order the results.

Video displays the issue: https://www.loom.com/share/034d9ff1f5224af1aaf67e5a424f5b62

Logs

No response

Environment

Environment
Application Name: Website
Laravel Version: 11.13.0
PHP Version: 8.3.7
Composer Version: 2.7.7
Environment: local
Debug Mode: ENABLED
URL: website.test
Maintenance Mode: OFF
Timezone: UTC
Locale: en

Cache
Config: CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: pusher
Cache: file
Database: sqlite
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 4
Sites: 3
Stache Watcher: Enabled
Static Caching: Disabled
Version: 5.12.0 PRO

Statamic Addons
alt-design/alt-redirect: 1.3.2
jacksleight/statamic-bard-texstyle: 3.2.2
statamic/collaboration: 1.0.0
statamic/seo-pro: 6.0.3

Installation

Fresh statamic/statamic site via CLI

Additional details

This error occurs when using an S3 bucket as an assets container, we also have the below index on the assets container:

'assets' => [
      'driver' => 'local',
      'searchables' => 'assets:assets',
      'fields' => ['path'],
      'settings' => [ 
          'query_mode' => 'words',
      ],
  ],
@duncanmcclean
Copy link
Member

This was fixed in v5.24.0, by #10709.

@mattmultiplied
Copy link
Author

mattmultiplied commented Sep 16, 2024

@duncanmcclean - This still doesn't work when you have a local index applied on the assets container.

It works when using the default search, but when you apply the below is what is causing it to stop working.

'assets' => [
      'driver' => 'local',
      'searchables' => 'assets:assets',
      'fields' => ['path'],
      'settings' => [ 
          'query_mode' => 'words',
      ],
  ],

Does using a local index allow for the assets to be sorted via their size?

@duncanmcclean
Copy link
Member

Which field are you trying to sort by?

When you have a search index configured, you'll need the relevant fields to be indexed or it won't be able to sort by them. For example: if you're wanting to sort by "Size", you'll need to add size to your index's fields array.

@mattmultiplied
Copy link
Author

Which field are you trying to sort by?

When you have a search index configured, you'll need the relevant fields to be indexed or it won't be able to sort by them. For example: if you're wanting to sort by "Size", you'll need to add size to your index's fields array.

Ahh yes apologies, that works - Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants