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

Support for indexing serialized arrays #346

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mweimerskirch
Copy link

@mweimerskirch mweimerskirch commented Nov 29, 2017

If the value is an array, recursively "implode" all values with a linebreak character.
Many plugins store data (e. g. repeatable text boxes) as serialized arrays in the post_meta table. This change makes it easier to index them properly without indexing control characters or array index names.

@danielbachhuber
Copy link
Contributor

Hi @mweimerskirch,

Thanks for the pull request. Could you open an issue first so we can discuss before you spend too much time on the implementation? Including additional details on your use case, etc. would be great.

@mweimerskirch
Copy link
Author

@danielbachhuber I'm used to discussing these details right in the pull request, as comments can be added to the commit and I can later on easily "rebase" the code and replace the commit.
But yes, I can create an issue.

Copy link
Contributor

@danielbachhuber danielbachhuber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you fix the failed build, and add a test case for this scenario?

@cjcodes
Copy link

cjcodes commented Dec 11, 2017

Two notes on this:

The schema won't like this--*_s does not support multiValued.

I would also recommend handling integer/float/decimal values, so you may want to move the checker up a bit.

And finally, *_i, *_d, and *_f don't support multiValued either, so would be worth submitting a patch against that as well.

(I'm handling these manually myself via the solr_build_document filter, but these suggestions would make it a bit easier.)

EDIT:
Correction to above. It looks like you're just concatenating instead of using Solr's multi-value support. I would recommend passing addField() an array instead so you could search by any of the values in an array, rather than all of them simultaneously. This makes faceted search much more graceful.

@danielbachhuber
Copy link
Contributor

@cjcodes Did you come up with a good solution for this that you'd want to submit a pull request for?

If the value is an array, recursively "implode" all values with a linebreak character.
Many plugins store data (e. g. repeatable text boxes) as serialized arrays in the post_meta table. This changes makes it easier to index them properly without indexing control characters or array index names.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants