All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

Low Search with Select2 fields

Tiziano 7 Mar 2019 10:48 question, complete

Hello there!

I'm using Low Search 6.1.3. and EE 5.1.3.

For a channel I use Select2 fields (https://devot-ee.com/add-ons/select2) to fill contents.

It is possibile search entries using Select2 fields?

If I use Select2 field(s) as parameter, search results are not returned. If I remove that field(s) all works great.

Thanks in advance,

Tiziano

Replies

  1. Low 7 Mar 2019 12:11

    You should be able to search that field's content just fine. How are you using it as a parameter? You can use http://pastebin.com/ for large chunks of code.

  2. Tiziano 7 Mar 2019 16:38

    Hi there! Thanks for your reply.

    Yes, I'm using it as parameter, my URL for result page is (with GET params)

    http://localhost:8888/retailers/resul...

    and “ country_retailer” is my Select2 field.

    Here below my code:
    - template with form: retailers/index ⇒ https://pastebin.com/n3CxVWLG
    - template with results: retailers/results ⇒ https://pastebin.com/FbRxY8nX

    I will wait for your update. Thanks again,

    Tiziano

  3. Low 7 Mar 2019 17:45

    Can the country_retailer field contain multiple countries, perhaps? Looking at the parameters, LS will try to find exact matches of the value for that field. So, the field should exactly match 'IT', not contain 'IT'.

    You could check the database to be absolutely certain -- not sure how Select2 will save its values to the DB. Look up either exp_channel_data.field_id_x (where x is that field's id) or exp_channel_data_field_x.field_id_x (again where x is that field's id), and see what is actually stored in that column.

  4. Tiziano 8 Mar 2019 11:28

    Hi!

    Select2 fields are populated from 3 custom tables on database (attached a screenshot of yd_coutries, other ones, for provinces and states, are pretty similar). The fields are linked to values with a config on field manager (please refer to attached screenshot).

    Before using Low Search we using Solspase SuperSearch and the search works fine, ad we switch to Low Search because of EE5.

    There is a way to make it work in this situation?

    Thanks,

    Tiziano



  5. Low 8 Mar 2019 11:52

    How the field options are populated isn't relevant; it's how it saves its selected value in EE's table: either exp_channel_data.field_id_x (where x is that field's id) or exp_channel_data_field_x.field_id_x (again where x is that field's id).

    But it's probably quicker if I take a look myself. Please send SuperAdmin login credentials to hi at gotolow dot com if you can.

  6. Tiziano 8 Mar 2019 13:27

    Sorry about that! Attached a screenshot of exp_channel_data (these fields are created on EE2, before migrating to EE5) for the 3 Select2 fields.

    There is a elegant way to search on them with Low Search?

    Thanks again,

    Tiziano

  7. Low 8 Mar 2019 14:10

    Okay, so, you should be searching for the full label (ie. "italy" rather than "IT"), and since the field itself contains a json string, you should not use the exact="" parameter. Try omitting it or substitute it for the contains_words="" parameter.

  8. Tiziano 8 Mar 2019 14:50

    Ok, great. Now it works ;)

    Thanks again for your support!