I have a data table with linked data. so for example it could be organization data type and in it users.
Now how can I make a do a search for expression that will search in organization but will also fetch results if they match a certain field in the users type that are present in the organization records?
There are many ways to do this, the optimal one depends on your particular use-case.
Youâll have to give more details about what you are trying to do, mainly
are you filtering on companies and users at the same time? IE return the companies matching filters AND companies with user matching filters, or do you sometimes want to filter on companies and other times on users.
what parameters are you filtering with? give real examples.
The basic solution is to run a search for Users instead of searching for Companies. Once you have the matching users, use the Userâs Company to output their company.
Iâm trying to search all fields at once. IE A searchbar where a user inputs some text and is expected to get results with any field matching the result.
So if a user searches for âjohnâ that should bring result whether its a userâs first name or an organization name
Quick and dirty method would be to merge two separate searches:
Do a search for Company merged with Do a search for Users: each items company. If you want to match with any field, you could use the âany fieldâ search constraint. I donât use it much because i donât like this method, so Iâm not sure how effective/performant it is, but you can give it a try.
The more elegant way would be to create a âSearchâ datatype satellite, where you will create a thing for every searchable thing, be it a company or a user (you can add more in the future). Add a field for âCompanyâ , this will either have the company itself or the userâs company, and add a text field that contains all searchable terms; full name, organisation name, occupation, etc⌠Instead of searching for companies or users, search for this new datatype using the constraint Text field contains Input value.
Did you mean interesct two searches or merge two searchs?
I think merging 2 searches would give more results than intended.
If Iâm getting it right than I think the problem with that mehtod is that it wouldnât work well with âignore empty constraintsâ (which I need).
The seatliite data type is what I thought to go with, but wanted to make sure if there are any other better way, as using it will create a potential duplication of data.
Yes thats a good point and itâs important to think about this, however itâs not necessarily a roadblock and it can be worked around.
If the search-bar is the only filter applied to the searches then its not a problem at all, because when the search bar is empty, then the search should return all companies anyways. (All companies allowed by privacy rules).
If you have other filters/search constraints, then there are ways to handle this, but it depends on what the other filters are. Could you give some examples show your current setup?
Just to be clear, It will definitely cause duplication of data. What do you mean by potentially? You can make sure that the data in the two data types is in synch using backend trigger workflows.
Yes there are other filters/search constraints which are coming from a different part of the system and filtering specific fields. For example a list of checkboxes each containing a âzoneâ attirbute of the user type and the user can select one or multiple zones to filter out the data.