2

Am I correct in saying you cannot search for specific text in a table field. e.g.

Table Fields Might hold the following data:

  • SKU1
  • SKU2
  • SKU3
  • SKU33

I then want to search for items that only return SKU3 not SKU33.

body::salty search will not work because i believe the field is stored as JSON.

1

If you're looking to see if the search term matches any row/column value in the field, then it should work: myTableFieldHandle::SKU3

If you are looking to find the exact row/column that matched, you'd have to do some custom development.

Even though a table field's data is stored as a JSON blob in the Craft content table, search index keywords are extracted from every row/column and saved as a single row in the search index table.

  • Just looked into this. If i search for SKU then SKU3 will still return. Wouldn't it be easy to add multiple Index Rows for each column/row of data. This way people can search for exact values within a column. It shouldn't cause any problems with how the search works now but adds the benefit of column exact search. The only work around i can see at the moment is to search like this: myTableFieldHandle::"SKU %" – Dean Sanderson Nov 21 '18 at 17:05
  • Currently the search index is indexed on a per field, per site basis, so it would be a bit of a change. – Brad Bell Nov 22 '18 at 0:10
2

Yeah because the data is stored as a JSON blob, I'm not sure this is going to be possible without retrieving all the data, parsing the JSON, then doing the exact match search via PHP, and then returning the results subset.

  • As i expect. Not sure how the search index works, but i am sure it wouldn't take that much work to split the table data into the search index? EG Column 1, Column 2 SKU1, TITLE SKU2, TITLE Index linking to that field and entry SKU1 SKU2 TITLE TITLE – Dean Sanderson Nov 17 '18 at 11:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.