-
Notifications
You must be signed in to change notification settings - Fork 729
How to use custom Gson instance's serializer/deserializer for query building? #69
Comments
With this line you are bypassing the Jest's serialization process and using the Elasticsearch API's QueryBuilder for it; so your custom Gson instance is never even taken into account. This would work as expected (although not the most elegant):
|
Hello, thank you for your answer. I completely forgot that I tried your solution, but my Dates ended up in the same format because whether I pass a
I guess my solution is to not use I'll update the post with my results. |
ah sorry, for a second i though your "ssb" object was a Jest class :) well if it's not then the code piece i posted earlier won't work either... |
Yeah. As I just figured out, |
You could also extend Jest's Search action class to accept Object as query parameter. AbstractAction already uses Object class as data/query property so JestHttpClient will use the custom Gson instance to serialize it. |
So if I make a custom Search(Object) class to avoid using |
Yes, I think so. |
Thank you, I think that solution will work for me. I ran into this issue #68, so I will post my results after I update and build Jest. |
Several issues:
My custom class has a I know you guys are working on centralizing the |
p.s.: sorry for the late reply. |
Hey, thanks for the response! I was able to get the test working and built myself a working version from source. I did it using a
I also modified the local copy of my code to pass the Gson instance from |
@kramer, thanks for the notification. I had forked the old code and used a custom build temporarily, so I will use your new code in the coming week. I will report back with results when I do. |
Closing issue as this is now resolved in release 0.0.5. |
I have the following serializer and deserializer for java.util.Dates:
I then associate it with my Jest client as such:
Indexing happens correctly (Dates are stored as milliseconds since epoch). Search queries do not produce milliseconds using my serializer/deserializer. I have the following serach query, where 'from' and 'to' are java.util.Dates:
It generates the following query:
I expected the query to produce from' and 'to' into milliseconds, as shown below.
Am I doing this incorrectly, or is this feature not implemented?
I also saw this thread: http://stackoverflow.com/questions/7910734/gsonbuilder-setdateformat-for-2011-10-26t202959-0700 but that answer requires upgrading to Java 7, which will probably not be an option for me.
The text was updated successfully, but these errors were encountered: