Calculating API Query Complexity Score

When you perform an API request one of the values returned in your results is a "score" value. This "score" value is basically a calculation of the complexity of your query. 

The more complex your search query, the higher your score will be.

What is the maximum score?

We consider a query with a complexity score of 10,000 or greater to be too complex and should be simplified.

What happens if the score is over 10,000?

Currently, you run the risk of your query timing-out and the search failing.

Eventually, we will ban all queries that have scores greater than 10,000.

Why measure a query's complexity?

We often see queries with 100s of keywords and 1000s of merchants included in the query. This results in long wait times for results to be returned.

How can I reduce a query's complexity score?

There are a few easy ways to reduce your query's complexity score:

  1. Reduce the number of merchants included in your search. We recommend less than 500.
  2. Reduce the number of keywords used in your search filters. We recommend less than 50.
  3. Reduce the usage of OR, NEGATIVE and QUORUM operators (see below)

How is the score calculated?

The score value is calculated by analyzing your query and summing values of various search parameters. Currently, here's how we calculate your score however the algorithm could change at any time.

OR operator = 80

Each time the OR "|" operator is used, 80 is added to the overall "score" value.

color LIKE red | blue

QUOTE operator = 80

Each time a phrase is quoted, 80 is added to the overall "score" value.

name LIKE "grumpy cat"

QUORUM operator = 80

Each time the quorum operator is used, 80 is added to the overall "score" value.

name LIKE "patagonia puff jacket hoodie"~3

NEGATIVE operator = 10

Each time a word is negated, 10 is added to the overall "score" value.

name LIKE -cat

LIKE operator = 10

Each time a LIKE operator is used, 10 is added to the overall "score" value.

network LIKE spain

NOT LIKE operator = 10

Each time a ! LIKE operator is used, 10 is added to the overall "score" value.

merchant ! LIKE sports

IN operator = 5

Each time an item is added to the array of values, 5 is added to the overall "score" value.

merchant_id IN (1,2,3)

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us