Building a segment to find multi-word search queries | Adobe Higher Education
Skip to main content
January 15, 2025
Répondu

Building a segment to find multi-word search queries

I have a dimension that gives me search queries, most of which are one word ... but I want to find all those that are 2 or more words.

I used segment builder to create a filtering on "contains" for " " and ' '.

The end result is the system delivers only queries that contain either ' or "  - interesting that this exists but absolutely not what I wanted.

Any ideas????

Meilleure réponse par Jennifer_Dungan

Lol, so it does... I swear it used to trim whitespace and not accept a space on its own.. I figured that was why they were trying to use " ".

 

Yeah, no need to use classifications then... unless you need to get groups by number of words (1 word, 2 words, 3 words,....  5+ words)

2 commentaires

Jennifer_Dungan
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
January 15, 2025

Lol, yeah, unfortunately, the segment builder is looking at the literal " or ' text... there is no "advanced" way of searching for an actual space... at least not here.

 

You could create a classification on your Search Query dimension though, and use regex to identify if there are spaces.

 

So I did a quick test, using regextester.com:

 

 

You can also check for "no space":

 

 

This will match if there is any space...  So if it matches, this should mean there is more than one word (unless the search query was " something" or "something " and the space wasn't trimmed from the from or end of the query)

 

So, in your Classification, I would first put in a catchall (or specifically use the no space regex), that sets the "has multiple words" (whatever you call it) to "no" or "false" or "single word" however you want to indicate that, then check for space, and set the classification to the opposite ("yes" or "true" or "multiple words").

 

If you need to get fancy and look for the number of words, I don't think you can get a count out directly, but you could get fancy and look specifically for one space, two spaces, three spaces, etc... then have a "5 or more" rule at the end.

 

However you end up setting it up, know that Classifications process every 4-6 hours, so you can't use it on "today's data" too reliably... but your classification rule can process up to 6 months of data in the past, so you should be able to have a history available to you once the initial processing is complete.

 

Now, when you create your segment, instead of using your Search Query dimension directly, you can use your new classification, and look for "yes" or "true" or "multiple words", or whatever value you set when there is a space.

Jennifer_Dungan
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
January 15, 2025

Now, depending on your needs, a classification may be a lot of work...

 

You could also just use the filter option on your table to search for space?

 

(There is a space there, you just can't see it)

 

 

It works for me on my Search Keywords dimension.

 

 

However, if this needs to be combined with other uses, like "percent of searches with multiple words" or something else that requires the use of a segment, then the classification thing is probably your only option (short of adding a new JS solution in Launch to evaluate the number of words in the search and pass that as a new dimension)... 

MandyGeorge
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
January 15, 2025

Is there a reason you didn't just put a space in the segment builder without the quotes? Using a space in the segment builder does work.

Just do what you were doing, except get rid of the quotes, just put a space.

 

 

Jennifer_Dungan
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
January 15, 2025

Lol, so it does... I swear it used to trim whitespace and not accept a space on its own.. I figured that was why they were trying to use " ".

 

Yeah, no need to use classifications then... unless you need to get groups by number of words (1 word, 2 words, 3 words,....  5+ words)

DerekRe6Auteur
January 16, 2025

Thanks - as you said - it used to trim spaces but now it doesn't - great