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

[5.x]: Default title field not being indexed for entry types #15025

Closed
pascalminator opened this issue May 18, 2024 · 5 comments
Closed

[5.x]: Default title field not being indexed for entry types #15025

pascalminator opened this issue May 18, 2024 · 5 comments
Assignees
Labels

Comments

@pascalminator
Copy link

What happened?

Description

The default title field is being indexed correctly for sections, and I can search and get results appropriately. However, the same default title field is not being indexed when used inside an entry type for a Matrix block (see attached screenshot below for better context).

Steps to reproduce

  1. Add an entry type to a section and keep the default title field.
  2. Save any value in the title field.
  3. Try to search for the value saved in the title field.
  4. No results are found for the title field within the Matrix block entry type.

Expected behavior

All "title" fields should be indexed, no matter where they are used. Ideally, the system should index the title fields within Matrix blocks just as it does for sections. Alternatively, there should be an option to control this indexing behavior with a checkbox, similar to custom fields.

Actual behavior

The default title field within Matrix block entry types is not being indexed, preventing searches from returning results for values in these title fields.

index-issue-title

Craft CMS version

5.1.3

PHP version

8.2

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

No response

@i-just
Copy link
Contributor

i-just commented May 20, 2024

Hi, thanks for reaching out. The title field is always indexed, even for the entries inside a matrix field.

For example, I have a top-level entry titled “vegetables” with a CKEditor and Matrix fields in it (both have “Use this field’s values as search keywords” off). CKEditor has a nested entry titled “carrots”, and the matrix field has two nested entries titled “broccoli” and “okra”; all 4 keywords are showing in the searchindex table.
Screenshot 2024-05-20 at 10 31 31

In the control panel > Entries > All, I can search for “vegetables” and get one entry as a result, but searching for “broccoli” returns zero results. This is expected behaviour as the control panel search will search for the entries in the specified sections, and the nested entries don’t belong to a section.

There’s also this discussion, which you might find helpful. It clarifies the opposite of the behaviour you’re describing: #14978.

I hope this helps!

I’ll close this now, but feel free to reply if you run into any further problems.

@i-just i-just closed this as completed May 20, 2024
@pascalminator
Copy link
Author

This situation is problematic for the search feature on the front-end in my eyes. The only workaround I've found is to disable the default title field and create a custom title field with the "Use this field’s values as search keywords" checkbox checked.

For example, I created a matrix to manage the content of my "about" page. However, I can't get search results for "Christine Tremblay" (because it's using the default title field), while I can get results for "Directrice générale" (because it's a custom field with "Use this field’s values as search keywords" enabled).

This discrepancy means that default title fields within Matrix blocks are not behaving as expected in search functionality, leading to incomplete search results.

image
image
image

This problem makes the default title field pointless for many user cases IMHO. Replacing it with a custom title field fixes my problem, but I'd rather use the default field because, well, it's already there.

Thank you for your time and sorry if I don't get it maybe?

@brandonkelly brandonkelly self-assigned this May 28, 2024
@brandonkelly brandonkelly reopened this May 28, 2024
@craftcms craftcms deleted a comment from linear bot May 29, 2024
@brandonkelly
Copy link
Member

I was able to reproduce this, and fixed for the next release.

Realized there’s a related bug, where entries’ search indexes don’t get updated automatically for nested entries within Matrix fields, when the nested entries are edited directly. That’s fixed as well, but for Craft 5.2+ since the fix was a bit involved (a7d1780).

@brandonkelly
Copy link
Member

Craft 5.1.8 is out with that fix. Thanks again!

@pascalminator
Copy link
Author

I can confirm the problem is fixed now, after updating Craft to 5.1.8. Right in time to deploy this site in production!

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

3 participants