Skip to content

feat(scripts): update sample_datasets fetch url #4364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class SaveObjectsMovies
public static async Task Main(string[] args)
{
// read json file from url
var url = "https://dashboard.algolia.com/sample_datasets/movie.json";
var url = "https://dashboard.algolia.com/api/1/sample_datasets?type=movie";
var httpClient = new HttpClient();
var response = await httpClient.GetAsync(url);
var content = await response.Content.ReadAsStringAsync();
Expand Down
2 changes: 1 addition & 1 deletion templates/dart/guides/search/saveObjectsMovies.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ void main() async {

// read json file from url
final datasetRequest = await http.get(
Uri.parse('https://dashboard.algolia.com/sample_datasets/movie.json'));
Uri.parse('https://dashboard.algolia.com/api/1/sample_datasets?type=movie'));

if (datasetRequest.statusCode == 200) {
final moviesData = jsonDecode(datasetRequest.body);
Expand Down
2 changes: 1 addition & 1 deletion templates/go/guides/search/saveObjectsMovies.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func saveObjectsMovies() {
// read json file
url := "https://dashboard.algolia.com/sample_datasets/movie.json"
url := "https://dashboard.algolia.com/api/1/sample_datasets?type=movie"
response, err := http.Get(url)

if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion templates/java/guides/search/saveObjectsMovies.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
public class saveObjectsMovies {
public static void main(String[] args) throws Exception {
// Fetch sample dataset
URL url = new URI("https://dashboard.algolia.com/sample_datasets/movie.json").toURL();
URL url = new URI("https://dashboard.algolia.com/api/1/sample_datasets?type=movie").toURL();
InputStream stream = url.openStream();
ObjectMapper mapper = new ObjectMapper();
List<JsonNode> movies = mapper.readValue(stream, new TypeReference<List<JsonNode>>() {});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// Fetch and index objects in Algolia
const processRecords = async () => {
const datasetRequest = await fetch('https://dashboard.algolia.com/sample_datasets/movie.json');
const datasetRequest = await fetch('https://dashboard.algolia.com/api/1/sample_datasets?type=movie');
const movies = await datasetRequest.json();
return {{#dynamicSnippet}}saveObjectsMovies{{/dynamicSnippet}}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import kotlinx.serialization.json.JsonObject
import java.net.URI

suspend fun main() {
val url = URI.create("https://dashboard.algolia.com/sample_datasets/movie.json")
val url = URI.create("https://dashboard.algolia.com/api/1/sample_datasets?type=movie")
val json = url.toURL().readText()
val movies: List<JsonObject> = Json.decodeFromString(ListSerializer(JsonObject.serializer()), json)

Expand Down
2 changes: 1 addition & 1 deletion templates/php/guides/search/saveObjectsMovies.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require(__DIR__."/vendor/autoload.php");
{{> snippets/import}}

// Fetch sample dataset
$url = "https://dashboard.algolia.com/sample_datasets/movie.json";
$url = "https://dashboard.algolia.com/api/1/sample_datasets?type=movie";
$response = file_get_contents($url);
$movies = json_decode($response, true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import requests

async def main():
# Fetch sample dataset
url = "https://dashboard.algolia.com/sample_datasets/movie.json"
url = "https://dashboard.algolia.com/api/1/sample_datasets?type=movie"
movies = requests.get(url).json()

# Connect and authenticate with your Algolia app
Expand Down
2 changes: 1 addition & 1 deletion templates/ruby/guides/search/saveObjectsMovies.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ require 'uri'
{{> snippets/import}}

# Fetch sample dataset
uri = URI('https://dashboard.algolia.com/sample_datasets/movie.json')
uri = URI('https://dashboard.algolia.com/api/1/sample_datasets?type=movie')
response = Net::HTTP.get_response(uri)
movies = JSON.parse(response.body)

Expand Down
2 changes: 1 addition & 1 deletion templates/scala/guides/search/saveObjectsMovies.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ object Main {
implicit val formats: org.json4s.Formats = org.json4s.DefaultFormats

// Fetch sample dataset
val url = "https://dashboard.algolia.com/sample_datasets/movie.json"
val url = "https://dashboard.algolia.com/api/1/sample_datasets?type=movie"
val result = Source.fromURL(url).mkString
val movies = JsonMethods.parse(result).extract[Seq[Map[String, Any]]]

Expand Down
2 changes: 1 addition & 1 deletion templates/swift/guides/search/saveObjectsMovies.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Core
{{> snippets/import}}

func saveObjectsMovies() async throws {
let url = URL(string: "https://dashboard.algolia.com/sample_datasets/movie.json")!
let url = URL(string: "https://dashboard.algolia.com/api/1/sample_datasets?type=movie")!
var data: Data? = nil
#if os(Linux) // For linux interop
(data, _) = try await URLSession.shared.asyncData(for: URLRequest(url: url))
Expand Down