How to boost an entity based on a query lenght

Hi there, I am trying to boost an entity based on the lenght of the query.

To be more specific.

MBE is a shipping company, they offer different products but among all shipping.

We cannot enter their DB for picking a specific traffic code, so we created a Product card for Tracking. However users go to theri website and look for the shipping code.

Their code have a specific numeric lenght 398464024740 → 12 numerical digits.

I would like to add a rule so that if the query is 12 numerical digits long, the product card “Track Shipping” will be boosted.

Can we do it?

Thank you.

Lucas B.

Hi Lucas,

We certainly can do it! You can use query rules, specifically regex, to target specific numeric strings to boost a certain entity.

To target a 12-digit string, your regex expression is: \b\d{12}\b. You can find a breakdown of this regex here.

If using the JSON editor your rule would look something like:

“rules”: [
{
“criteria”: {
“searchTermMatchesRegex”: \b\d{12}\b
},
“actions”: [
{
“actionType”: “BOOST_ENTITIES”,
“entityIds”: [
“Product-0”
],
“verticalKey”: “faqs”
}
]
}
]

Thank you Henry.

While the query is correct, if I put it in Json I get the following error.
“Invalid escape character in string.”

  • I have modified all quotations to match the once in our system.

Do you know what it could be?

Thank you.

Lucas B.

Hi Henry.

I have just tested it and it seems that our system accepts the rejex with 2 back-slashers \b\d{12}\b