-
-
Notifications
You must be signed in to change notification settings - Fork 550
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
Search results missing "search_snippets" #11398
Comments
I found a possible workaround in this file vendor/statamic/cms/src/Search/Comb/Comb.php, in this part of code (around line 608)
and by removing the check on $j, the search_snippets now correctly include matches that have only one searched item. |
I'm guessing the issue is your first chunk isnt setting $matched to true. it probably needs changed to
|
Hi @ryanmitchell, yes it seems working in this way. 👍 |
If you have a potential fix, feel free to open a pull request and we can take a look when we have time. |
Hi @duncanmcclean , I'm using successfully this little fix from a while (the cleaner proposal of @ryanmitchell ) so now I tried to open a PR #11450 but the checks fail for some lint reasons that I don't see... could you have a look please? thanks |
Bug description
I noticed that if I search for two words, the search_snippets array is populated only when the item found contains both words (even if they aren't on the same line). However, if the search result contains only one of the searched words, the search_snippets array remains empty.
I'm using the the native local driver, not algolia.
Is this some kind of limitation, a bug, or could I be missing some configuration parameters in the indexes?
Thanks!
How to reproduce
Simply create an index, for example my pages below, on the collection of static pages, and then run a search using two or more words to find (choosing them knowing that only one is present on a specific target page).
'pages' => [ 'driver' => 'local', 'searchables' => 'collection:*', 'fields' => ['title','main_body','description_block'], ],
Then dump the results and look into the structure, checking the search_snippets array, you will find an empty one.
Logs
Environment
Installation
Fresh statamic/statamic site via CLI
Additional details
No response
The text was updated successfully, but these errors were encountered: