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. :::
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.
- Java 11+
- Maven
- Typesense server (v28.0) running on localhost:8108
- Clone this repository
- Make sure your Typesense server is running
- Update the Typesense connection settings in
TypesenseTest.java
if needed (host, port, API key)
-
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>
-
Build and run the test:
mvn clean compile mvn exec:java -Dexec.mainClass="com.typesense.test.TypesenseTest"
-
Expected result:
- Document with ID
test@company.com
is created successfully - Document can be retrieved with the original ID
- Document with ID
-
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>
-
Update the TypesenseTest.java file to use the v1.3.0 API (shown in the file)
-
Build and run the test:
mvn clean compile mvn exec:java -Dexec.mainClass="com.typesense.test.TypesenseTest"
-
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
- When trying to retrieve a document created with v0.5.0, using the original ID (
Make sure you're using the correct Maven dependency and import statements for the version you're testing with.