Skip to content

guides: push records.json location [skip-bc] #4196

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 2 commits into from
Dec 4, 2024
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
2 changes: 1 addition & 1 deletion templates/csharp/guides/ingestion/pushSetup.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class PushSetup
{
public static async Task Main(string[] args)
{
string jsonContent = File.ReadAllText("/my-raw-records.json");
string jsonContent = File.ReadAllText("records.json");

var records = JsonSerializer.Deserialize<List<PushTaskRecords>>(jsonContent);

Expand Down
2 changes: 1 addition & 1 deletion templates/go/guides/ingestion/pushSetup.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func push() {
// use the region matching your applicationID
{{> snippets/init}}

content, err := os.ReadFile("/my-raw-records.json")
content, err := os.ReadFile("records.json")
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion templates/java/guides/ingestion/pushSetup.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import java.util.Map;

public class pushSetup {
public static void main(String[] args) throws Exception {
JsonNode content = new ObjectMapper().readTree(new File("/my-raw-records.json"));
JsonNode content = new ObjectMapper().readTree(new File("records.json"));
List<PushTaskRecords> records = new ObjectMapper().readerForListOf(Map.class).readValue(content);

// use the region matching your applicationID
Expand Down
2 changes: 1 addition & 1 deletion templates/javascript/guides/ingestion/pushSetup.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { PushTaskRecords } from 'algoliasearch';

try {
// read local JSON file containing array of records
const records = JSON.parse(fs.readFileSync('/my-raw-records.json', 'utf8')) as PushTaskRecords[];
const records = JSON.parse(fs.readFileSync('records.json', 'utf8')) as PushTaskRecords[];

// push records to the API
const run = {{#dynamicSnippet}}pushSetup{{/dynamicSnippet}}
Expand Down
2 changes: 1 addition & 1 deletion templates/kotlin/guides/ingestion/pushSetup.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import kotlinx.serialization.json.JsonObject
import java.io.File

suspend fun main() {
val json = File("/my-raw-records.json").readText()
val json = File("records.json").readText()
val records: List<PushTaskRecords> = Json.decodeFromString(ListSerializer(PushTaskRecords.serializer()), json)

// use the region matching your applicationID
Expand Down
2 changes: 1 addition & 1 deletion templates/php/guides/ingestion/pushSetup.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require(__DIR__."/vendor/autoload.php");
{{> snippets/import}}

$records = json_decode(file_get_contents("/my-raw-records.json"), true);
$records = json_decode(file_get_contents("records.json"), true);

// use the region matching your applicationID
{{> snippets/init}}
Expand Down
2 changes: 1 addition & 1 deletion templates/python/guides/ingestion/pushSetup.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ async def main():
# use the region matching your applicationID
_{{> snippets/init}}

with open("/my-raw-records.json") as f:
with open("records.json") as f:
records = json.load(f)

run = {{#dynamicSnippet}}pushSetup{{/dynamicSnippet}}
Expand Down
2 changes: 1 addition & 1 deletion templates/ruby/guides/ingestion/pushSetup.mustache
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'json'
{{> snippets/import}}

records = JSON.parse(File.read('/my-raw-records.json'))
records = JSON.parse(File.read('records.json'))

# use the region matching your applicationID
{{> snippets/init}}
Expand Down
2 changes: 1 addition & 1 deletion templates/scala/guides/ingestion/pushSetup.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ object PushSetup {
implicit val ec: ExecutionContextExecutor = scala.concurrent.ExecutionContext.global
implicit val formats: org.json4s.Formats = org.json4s.DefaultFormats

val result = Source.fromFile("/my-raw-records.json").getLines().mkString
val result = Source.fromFile("records.json").getLines().mkString
val records = JsonMethods.parse(result).extract[Seq[algoliasearch.ingestion.PushTaskRecords]]

// use the region matching your applicationID
Expand Down
2 changes: 1 addition & 1 deletion templates/swift/guides/ingestion/pushSetup.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Core
func pushSetup() async throws {
do {
let path = URL(string: #file)!.deletingLastPathComponent()
.appendingPathComponent("/my-raw-records.json")
.appendingPathComponent("records.json")
let data = try Data(contentsOf: URL(fileURLWithPath: path.absoluteString))
let records = try JSONDecoder().decode([PushTaskRecords].self, from: data)

Expand Down
Loading