Description
With the SpEL expression support in @Query
introduced in #2826, here comes a new ConversionService
with ElasticsearchCollectionValueToStringConverter
and ElasticsearchStringValueToStringConverter
to convert the query values in elasticsearch query. We don't register these two converters into the default ConversionService
on purpose to avoid the misconversion in a common situation(eg, common string to string doesn't need quotation escape).
However, Converter
s configured by users are registered into the default ConversionService
rather than this one, so it doesn't have the ability to convert custom object(for example SampleProperty
) when using SpEL:
@Query("""
{
"bool":{
"must":[
{
"term":{
"sample_property": "#{#sampleProperty}"
}
}
]
}
}
""")
SearchHits<SampleEntity> queryBySamplePropertySpEL(SampleProperty sampleProperty);
So we should:
- propose1: unify the two
ConversionService
. Let the newConversionService
have all the ability the defaultConversionService
have, not vise versa;
Another problem is that when using placeholder(?0
, ?1
...) in @Query
, null
value will be converted to string "null"
, and this should be considered a bug as stated in #2826 (comment). The simplest way to deal with that is to use the new ConversionService
in StringQueryUtil
, since the conversion logic has already been well handled in ConversionService
.
- propose2: replece the old logic for values conversion in
StringQueryUtil
;