Skip to content

Instantly share code, notes, and snippets.

@JasonStoltz
Created June 27, 2019 20:33
Show Gist options
  • Save JasonStoltz/c5615f15936e3732b08d9bca84ba68a4 to your computer and use it in GitHub Desktop.
Save JasonStoltz/c5615f15936e3732b08d9bca84ba68a4 to your computer and use it in GitHub Desktop.
Medium - Search UI - 5
const configurationOptions = {
apiConnector: connector,
searchQuery: {
search_fields: {
// 1. Search by name of video game.
name: {}
},
// 2. Results: name of the video game, its genre, publisher, scores, and platform.
result_fields: {
name: {
// A snippet means that matching search terms will be highlighted via <em> tags.
snippet: {
size: 75, // Limit the snippet to 75 characters.
fallback: true // Fallback to a "raw" result.
}
},
genre: {
snippet: {
size: 50,
fallback: true
}
},
publisher: {
snippet: {
size: 50,
fallback: true
}
},
critic_score: {
// Scores are numeric, so we won't attempt to snippet these, we'll just use the raw
// value.
raw: {}
},
user_score: {
raw: {}
},
platform: {
snippet: {
size: 50,
fallback: true
}
},
image_url: {
raw: {}
}
},
// 3. Facet by scores, genre, publisher, and platform, which we'll use to build filters later.
facets: {
user_score: {
type: "range",
ranges: [
{ from: 0, to: 5, name: "Not good" },
{ from: 5, to: 7, name: "Not bad" },
{ from: 7, to: 9, name: "Pretty good" },
{ from: 9, to: 10, name: "Must play!" }
]
},
critic_score: {
type: "range",
ranges: [
{ from: 0, to: 50, name: "Not good" },
{ from: 50, to: 70, name: "Not bad" },
{ from: 70, to: 90, name: "Pretty good" },
{ from: 90, to: 100, name: "Must play!" }
]
},
genre: { type: "value", size: 100 },
publisher: { type: "value", size: 100 },
platform: { type: "value", size: 100 }
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment