Combining 3 user fields in the search action

example221515

Trying to get a more personal search for a user.

Each user has three keywords, that search users here, and each keyword has the same search, with the keywords 1-3 being the only difference.

Search works as expected. I’m wondering if we can sort items so that not only if the keyword matches, but also if two keywords match, it will show prior items where only one keyword matches.

Hope this is clear and we are able to find some logic here.

Thanks!

Hope I understood this… if not ooopss…

Since you are using 3 merged searches you are logically ORing the searches. But, you also want to logically AND the searches to allow for two (or 3) different search terms to have to be correct instead of only one within a search.

You can do this by using custom states within each search and leveraging the AND behavior within the Search.

Search (repeat the Keyword1 three times)
Keyword1=A
Keyword1=B
Keyword1=C.

If you want an internal logical AND then all that has to happens is A, B, or C need to contain different values. If you do not want a logical AND then A=B=C is the same as just Keyword1=A.

By using combination of the states within the searches you can create all the possible combinations using the 3 internal Keyword1 elements combined with the 3 merge Searches.

If others have a better idea I love to learn.
Cheers, John

1 Like

Okay, this sounds interesting idea! Thanks @jgellis!

I am 80% there, not understanding it 100% at the moment. Could you turn this into a practical example?

Don’t understand the midsection, Keyword1=A, Keyword1=B, Keyword1=C…

In this case, it’s only possible to have one value per keyword, 1 or 2 or 3.

The idea here is that if you have three keywords (hashtags, let’s say), and if I search for two hashtags, and you have those two hashtags (e.g., Keyword1 and Keyword2), I would find you much quicker among other 1000 members who are matching only with one keyword, so your profile will appear as the first in the search as you have more “matching accuracy,” if this makes sense?

There must be a way to accomplish this.

Hi there, @another… do the keywords need to be in separate fields? If you store the keywords as a list and you have a list of keywords you are searching for, you could get the desired result (if I understand your last reply correctly) by doing a count of the intersect between the lists in 3 merged searches.

The first search would return users where a count of the intersect between their list of keywords and the list of keywords in the search is 3, the second merged search would return users where the count is 2, and the third merged search would return users where the count is 1.

True, the counts would have to be done in advanced filters, and having 3 merged searches with 3 advanced filters could have a performance impact. Still, it should produce the desired result of users with more matching keywords appearing first, so I didn’t think it could hurt to throw it out there as food for thought.

Best…
Mike

1 Like

I would :

  1. use a database trigger to update the tag fields to a single field.

  2. then run through the list of users that match at least 1 tag and create a user-user record for each one that stores (or updates) the number of matches and adds to a list on the user.

That way you have a list of matching users that you can use a numeric fields to sort on.

2 Likes

@mikeloc and @NigelG! Great points! Really great points right there!

Now user has three keywords (1-3) as the separate fields = 3 fields

Should I make them to be one text field as a list?

While on other side we have three inputs, or three values in the states (it can be single or a list of text values), what I should do here? :smiley:

Looking forward to your respond! :smiley:

I obviously don’t know the details of your app, but if the keywords can be defined via an option set, I would likely go that route, and I would use list fields as I described.

1 Like

In the Search you can duplicate fields with different values then, the search ANDs them since all must be true.

1 Like

Hi @NigelG;
Are you suggesting concatenation, or creating a list?
I suspect concatenation so you can use the keywords search action, but if it is a list that would be cool and I would love to know how it works?

1 Like

Thanks @mikeloc and @jgellis!

Searching with three keywords (values) is done! It works, how we can now sort users by the number of matching values in relation to the three keywords on the list?

:smiley:

You can only sort outside of the search using data that is actually returned to the client by the search. Which idea did you finally use to make the search work the way you needed?

1 Like

Merging solution doesn’t work for the three (or two) keywords on the list in the states.

What work for now is if keyword 1, 2 or 3 containts a keyword.

Could you please clarify what means AND in your example? How do you achive the “AND”? I am seeing this as instead of “Merge with”, to have “AND”, but it doesn’t go like that…

Current situation is with state on the list (algorithm_list), which is list of texts, and we have Merged three searches, each search with only difference of Keyword1, 2 and 3.

example2512551

If we make the keyword1, 2 and 3 as a list as well (on the user level), this might work? @mikeloc (Combining 3 user fields in the search action - #4 by mikeloc)

How generally you guys create simple alrgorithms like this one, if we can call it an alrgorithm? No chance this is the limit here…

Aw, come on, @another… did you really need to ask me that question again? :slight_smile:

I said in both of my replies that I would use lists, and I wouldn’t use text for the keywords unless it was absolutely necessary because to me, text can be “messy.”

To be honest, I’m not smart enough to understand the suggestions that John and Nigel proposed, but I know that doing counts of intersects on lists does what you want here. Is it the “best” way to go? Who the hell knows anymore. But it is probably what I would do, and that’s why I suggested it in this thread… twice.

1 Like

Sorry @mikeloc Need to double, even make a tripple check, as the update is not a small, trying to figure it out what is the best way here, and see if more information can be seen around, and you have been a very helpful here, so thank you again for your contribution here. Now is clear to make the changge, from three separate keywords into one field (list).

Will make it first on the separate data type, as to not effect user’s modification time, and to test this feature in the weekly “algorithm” matching for users, rather make it alive for manual use as well.

@NigelG’s approach is matter of fact quite advance, don’t have experience with “database triggering”, not sure how it works, although have done bit of research about, at it seems to be mainly used for the updating related records all over the app which in this case I have done for the list of keywords where user can use existing keyword, or add a new.

Wondering do you guys have build any algorithms, for example to match different users, or for the feed? Thanks!

Yes, I am doing this right now.

The database trigger gathers up texts from various list fields and puts them all into a List of Tags field which is List of Texts. Not likely to run into List size issues.

For example we have a list of Topics and a List of Industries (which are option sets).

The user has both these fields. As does an Event.

The database trigger updates the list of tags on the User and Event. e.g. if the Event has Topics of Creative and Databases and Industries of Insurance and Banking then there would be a list of 4 text fields Creative, Database, Insurance, Banking

The User has the same field of Tags.

Each time an Event is created (again, it is a database trigger) I run a workflow that finds all the relevant users and for each User I schedule a Workflow for User and Event.

The workflow then does an Intersect of the User’s List of Tags and the Event’s List of Tags : Count

So if a user had the same tags as the Event I mentioned above, then the “score” is 4. But if another User had different Topics and Industries, they would get a score of 0.

So the table is User - Event matches
User - type User
Event - type Event
Score - number
Matching tags - list of texts (just there to work out what is happening really)

The user has a list -
List of Matching Events - Type User Event Matches (a list)
So now you can display a ranked list of Events by sorting the User’s List of Matching Events on Score Descending.

The only moderately complicated bit is that you need to check to see if the User and Event have already matched (so maybe someone updated the User or the Event tags) and update it if it exists or add a new one if not.

There is a separate workflow that runs when the user logs on, and it deletes any of the User’s Event matches that are past the date of the event.

You could do it with any two tables with lists of text tags (in fact we do it for many tables and lots of fields of text tags).

1 Like

Oh, this is very good information @NigelG!

Complimentary video: https://www.youtube.com/watch?v=6-A8MFWjQG4&ab_channel=BubbleTipLister

This is a much simpler method, instead of creating an additional action in the workflow, for example: when the user is uploading their profile :smiley:

Thanks all! It seems we got all of our answers in this thread :slight_smile:

Furthermore: Is it possible to create a Repeating group, to make the search easier, simpler? To have pegnation, or load more items condition, to make less impact on the performance. Any other work around for general use?

This topic was automatically closed after 70 days. New replies are no longer allowed.