Reconcile GeoPoint toString and fromString methods
GeoPoint.toString prints as a json array of values, but resetFromString expects comma delimited. This commit reconciles the methods.
This commit is contained in:
parent
ef33a74286
commit
dc07affff1
|
@ -146,7 +146,7 @@ public final class GeoPoint {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[" + lat + ", " + lon + "]";
|
||||
return lat + ", " + lon;
|
||||
}
|
||||
|
||||
public static GeoPoint parseFromLatLon(String latLon) {
|
||||
|
|
|
@ -338,7 +338,7 @@ public class StringFieldMapper extends FieldMapper implements AllFieldMapper.Inc
|
|||
*/
|
||||
public static ValueAndBoost parseCreateFieldForString(ParseContext context, String nullValue, float defaultBoost) throws IOException {
|
||||
if (context.externalValueSet()) {
|
||||
return new ValueAndBoost((String) context.externalValue(), defaultBoost);
|
||||
return new ValueAndBoost(context.externalValue().toString(), defaultBoost);
|
||||
}
|
||||
XContentParser parser = context.parser();
|
||||
if (parser.currentToken() == XContentParser.Token.VALUE_NULL) {
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.index.mapper.multifield;
|
|||
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
import org.elasticsearch.common.unit.DistanceUnit;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
|
@ -121,12 +122,13 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase {
|
|||
assertThat(bField.get("type").toString(), equalTo("string"));
|
||||
assertThat(bField.get("index").toString(), equalTo("not_analyzed"));
|
||||
|
||||
client().prepareIndex("my-index", "my-type", "1").setSource("a", "51,19").setRefresh(true).get();
|
||||
GeoPoint point = new GeoPoint(51, 19);
|
||||
client().prepareIndex("my-index", "my-type", "1").setSource("a", point.toString()).setRefresh(true).get();
|
||||
SearchResponse countResponse = client().prepareSearch("my-index").setSize(0)
|
||||
.setQuery(constantScoreQuery(geoDistanceQuery("a").point(51, 19).distance(50, DistanceUnit.KILOMETERS)))
|
||||
.get();
|
||||
assertThat(countResponse.getHits().totalHits(), equalTo(1l));
|
||||
countResponse = client().prepareSearch("my-index").setSize(0).setQuery(matchQuery("a.b", "51,19")).get();
|
||||
countResponse = client().prepareSearch("my-index").setSize(0).setQuery(matchQuery("a.b", point.toString())).get();
|
||||
assertThat(countResponse.getHits().totalHits(), equalTo(1l));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue