Skip Navigation

[Resolved] Search text on 2 custom fields

This support ticket is created 4 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 15 replies, has 2 voices.

Last updated by ericK-4 4 years, 9 months ago.

Assisted by: Minesh.

Author
Posts
#1546433

Hello,
I am still on the dev of my directory advocate site.
My client wants now that when the visitor search a town for advocate location
the result become now from 2 fields “Barreau” and “Ville” (“Ville“ is a repeatable group).
And this 2 fields return Towns name.
With Relevanssi I made searchable text for this 2 fields
In my search view I make a search field text but toolset returns as result
only the “Ville” field and not “Barreau” field
URL of the site :
hidden link
For example when you type “Jura” is a “Barreau” location, toolset retours no result
Thanks for your help

#1546881

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

You need to understand the thing that Barreau is the custom field that belongs to post Advocate and Ville is the field that belongs to the Repeating Field Group (which is maintained internally as relationship so all repeating field group entries will be a separate related post).

When you try to search within the repeating field group fields, you are displaying the parent post information using the item attribute. Something like the following shortcode:

[types field='prenom' item='@coordonnees.parent'][/types]

I see also you set ordering setting to order by Ville field, so when you are searching in post field Barreau, the Ville field will not be available and hance the view's query will be failed to return any results.

The way you want to build the custom search is not supported as you want to search in both parent post field and repeating field group field.

#1546921

Hi Minesh,
Ok ! and if I make the repeater group with “ville” field as a child the result will be the same I assume 🙁
The only solution to make a search on several fields is that these fields must belong to the same group of custom fields right ?
Best regards
Eric

#1546923

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes - as you are displaying the parent post information within the view that used to originally query the repeating field group, you need to add the Barreau field as the part of your repeating field group and then adjust the filters/query filters whatever required accordingly.

#1546941

Hi Minesh,
ok ! So I put the field “Barreau” in the repeater field with the field “ville”. So I can make a search for this 2 field. I am right ??
Best regards

#1546945

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes - theoretically, its true but as I said in my previous reply it may require some changes with query filter or it could work as you have the chance to index the custom field using the Relevanssi.
=> https://toolset.com/documentation/user-guides/views/searching-texts-custom-fields-views-relevanssi/

#1546949

My issue is resolved now. Thank you!

#1547403

Hi Minesh,

I put the “Barreau” field in the repeater group with the field “Villes”. Make the search text available for ville and barreau with Relevanssi. Make a text search in my view. But it doesn't work. Toolset give the result for the field “Ville” but not fpr the “Barreau“ it says that nothing is found 🙁
Thanks for your help

#1547881

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

When I searched for the text "Jura" - it does show me the results:
=> hidden link

Is this not the expected results?

#1547909

My issue is resolved now. Thank you!
My bad Minesh ! Excuse me forget to clear my cache 🙁

#1548625

Hi Minesh,

Just one more thing something doesn't work as expected
for example if I type “Lille”, toolset returns all the results that contains “Lille” in “ville“ field and “Barreau” field
But for example if I type “Tourcoing”, (the advocate works in “Tourcoing” and the “Barreau” is “Lille”), Toolset doesn't return all the advocate belonging in Lille but only the town. How can I achieve that ?
Thanks for your help

#1549673

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Do you mean when I search for the Tourcoing - it should return the advocates where “ville“ field and “Barreau” field have value equal to Tourcoing?

#1549817

Hi Minesh,

Not exactly. What I want is : If I type for example Tourcoing Toolset returns as result :
All the advocate that lives in Tourcoing -> Field : “Ville”
In this case Corinne Thullier but what is “missing” is all the advocate working in the same court (Lille)

An another example, if I type Roubaix Toolset returns as result : 4 advocates bu it is missing Corinne Thullier because she is working is Lille too.

Hoping that is clear
Thanks in advance

#1551947

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I understand what you are saying but you need to understand how view works as well.

If you are searching for the keyword Tourcoing - it will search for Tourcoing in both Barreau and Ville fields.

Because views do not know what keyword your Barreau field contains.

Views will return only results where the keyword you input matched with the field values.

#1559419

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Shane asked me to close this ticket. Would you mind to close this from your end and let me know if you face any difficulties with that.