Search in liked data type

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?

Thanks

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.

1 Like

Thank you so much for the reply.

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.

Thanks!

1 Like

It would need to be a merge.

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.

Thank you for the reply!

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.