当我搜索错误时,所有答案都指向使用.encode('utf-8')。我添加到我的代码,我仍然得到相同的错误。这是我的代码
public default List<StoreES> nearStores(Double latitude, Double longitude, String address, Integer page,
Integer size) {
DistanceSortBuilder distanceSortbuilder = SortBuilders.geoDistanceSort("location").point(latitude, longitude)
.order(SortOrder.ASC).unit(DistanceUnit.KILOMETERS);
SearchQuery query = new NativeSearchQueryBuilder().withQuery(QueryBuilders.matchAllQuery())
.withSort(distanceSortbuilder).withPageable(new PageRequest(page, size)).build();
FacetedPage<StoreES> storesPage = this.search(query);
List<StoreES> stores = storesPage.getContent();
// ##############calculate distance##################
for (StoreES store : stores) {
if (store.getLocation() != null) {
double distance = GeoDistance.DEFAULT.calculate(latitude, longitude, store.getLocation().getLat(),
store.getLocation().getLon(), DistanceUnit.KILOMETERS);
store.setDistance(distance);
}
store.setDistanceUnit(DistanceUnit.KILOMETERS.toString());
}
return stores;
}
registered.salt是bcrypt.gensalt()保存到我的数据库
答案 0 :(得分:2)
只要将字节保存到数据库中的文本字段,它们就会成为文本,因此您还需要对盐进行编码。