Skip to content
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

case classes with empty field #68

Open
a-tsioh opened this issue Apr 14, 2020 · 2 comments
Open

case classes with empty field #68

a-tsioh opened this issue Apr 14, 2020 · 2 comments
Assignees

Comments

@a-tsioh
Copy link

a-tsioh commented Apr 14, 2020

Thank you for this useful work !

I'm running into a problem when using case class to describe documents.
If for one document a text field value is an empty string (""), the document can be stored by Solr but the specific field will not be. Then at query time, the SolrClient seems unable to rebuild the document when I try to getResultsAs[MyCaseClass](...)

It seems to work with Option[String] (with Some("") becoming None though)

@takezoe takezoe self-assigned this Apr 17, 2020
@takezoe
Copy link
Owner

takezoe commented Apr 17, 2020

Thanks for reporting. Let me see on this weekend!

@takezoe
Copy link
Owner

takezoe commented Apr 18, 2020

@a-tsioh As long as I tested, Solr (or SolrJ) doesn't allow an empty string for a required string field while we can specify an empty string for optional string fields though these fields are not stored in the document.

Meanwhile, if a field doesn't exist in a document on Solr, solr-scala-client handles it as null. Then it's converted to null for String field or None for Option[String] field. This is an intentional behavior in solr-scala-client end.

I guess the field you tried to store an empty string is optional. Then you should use Option[String] and use None instead of an empty string even when you store documents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants