Building a platform to understand search queries
By: Pinterest Engineering
Tags: Pinterest, Discovery, Machine Learning, Search

Dong Wang | Pinterest engineer, Discovery

Millions of people use Pinterest as a visual discovery tool each day. Search is one of the primary tools that drives discovery on the site and across our apps. In order to help Pinners find what they’re searching for in the most effective ways, we must understand their intentions behind search queries.

Last April, we overhauled search with Guided Search. Since then, the average number of searches per person has increased by 25 percent. Here’s a look at ongoing work to improve the search experience and help people discover the most relevant results to them.

For example, when a person searches for “turkey” it’s not immediately clear whether he or she is looking for “turkey” recipes or “Turkey” travel or “turkey” animal. After the Pinner browses search results and issues another query, such as “turkey recipes,” we begin to understand the direction of the search. If the person is searching for recipes, we can then show more results related to turkey and food, such as “roast turkey” and “Thanksgiving turkey,” etc.

Data around the query

The more people search, the better we can suggest results. From the previous example, we can guess that the next person who issues the query “turkey” may also be interested in the “turkey recipes.” The information extracted from previous query log has shown to be effective in understanding the user’s search intent. Search context such as adjacent queries in the same search session and clicked Pins after submitting a search query can help us improve the discovery experience for future searches.

To capture the information about a search query and make it available for other applications to process, derive signals and build features on top of it, we designed a data collection called QueryJoin that contains the following data:

The search query, which is also the identifier for the QueryJoin.

Demographic stats such as gender, country or language.

Adjacent queries, which we store queries that appeared in the same session to learn how users refined their search queries to find things they were looking for.

Pins, as we store a set of Pins returned for the search query. For each Pin, we have aggregated data from the PinJoin (the data collection of a cluster of Pins with the same image signature and the information about those Pins) as well as some engagement stats like the number of clicks, repins and likes.

Data pipeline for the QueryJoin

We extract search activities from the session logs on a daily basis. For each search activity, we extract the information needed to build the QueryJoins and store them keyed by the date.

Every week, we create a partial QueryJoin by aggregating daily search activities together. For the Pins in the QueryJoin, we join them with PinJoins by image signatures. For each query, we find a set of PinJoins related to the query and then calculate the most relevant Pins and classify queries into categories. We also join the QueryJoin and the UserJoin (the collection of a user’s information such as their boards and Pins) by identifiers and calculate the gender and country stats.

In the end, we merged partial QueryJoins, built recently into a single QueryJoin as our knowledge platform for search and other discovery features.

Putting the knowledge platform in action

As a data platform, currently we use the data from the QueryJoin for many features.

Search autocomplete: QueryJoin is one of the main data sources for our search autocomplete feature. We extract popular queries based on QueryJoin’s vertical stats and index those queries in our autocomplete index.

Guided search: Queryjoin is an important source for generating the search guides and improving discovery on Pinterest.

Search relevance: We predict the search query’s category based on relevant Pins in the QueryJoin and then use the category for better search relevance tuning.

More to come

It’s challenging work to not only accurately understand a Pinner’s interests, but to also help them discover things they like and give them inspiration to do things in the real world. We’re just at the beginning of creating a new discovery experience. There are a lot of opportunities for us to improve the data quality, better understand user queries and improve user discovery experience.

Acknowledgements: This project was a joint effort of the whole Discovery team at Pinterest. If you’re interested in being part of it, join our team!

Dong Wang is a software engineer at Pinterest.

For Pinterest engineering news and updates, follow our engineering Pinterest, Facebook and Twitter. Interested in joining the team? Check out our Careers site.