Skip to content

tharropoulos/java-encoding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Typesense Java Client Document ID Encoding Issue Reproduction

This project attemps to reproduce an issue with document ID encoding in the Typesense Java client when using special characters like @ in document IDs.

:::warning The issue was not replicated. :::

Issue Description

When using document IDs containing special characters (like @ in emails):

  • In Typesense Java client v0.5.0: Document IDs are stored as-is and can be retrieved without URL encoding
  • In Typesense Java client v1.3.0: Document IDs are URL encoded when sent to the server, but the server expects exact matches

This causes an issue when documents are created with v0.5.0 and later accessed with v1.3.0, or when migrating between versions.

Prerequisites

  • Java 11+
  • Maven
  • Typesense server (v28.0) running on localhost:8108

Setup

  1. Clone this repository
  2. Make sure your Typesense server is running
  3. Update the Typesense connection settings in TypesenseTest.java if needed (host, port, API key)

Reproduction Steps

Test with Typesense Java Client v0.5.0

  1. Update pom.xml to use version 0.5.0:

    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <typesense.version>0.5.0</typesense.version>
    </properties>
  2. Build and run the test:

    mvn clean compile
    mvn exec:java -Dexec.mainClass="com.typesense.test.TypesenseTest"
  3. Expected result:

    • Document with ID test@company.com is created successfully
    • Document can be retrieved with the original ID

Test with Typesense Java Client v1.3.0

  1. Update pom.xml to use version 1.3.0:

    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <typesense.version>1.3.0</typesense.version>
    </properties>
  2. Update the TypesenseTest.java file to use the v1.3.0 API (shown in the file)

  3. Build and run the test:

    mvn clean compile
    mvn exec:java -Dexec.mainClass="com.typesense.test.TypesenseTest"
  4. Expected result:

    • When trying to retrieve a document created with v0.5.0, using the original ID (test@company.com), the retrieval fails
    • When using a manually encoded ID (test%40company.com), retrieval may or may not work depending on server behavior

Notes

Make sure you're using the correct Maven dependency and import statements for the version you're testing with.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages