-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Store arrays offsets for scaled float fields natively with synthetic source #125793
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
Changes from 6 commits
700a15b
a917387
11ed0ea
b98a829
ba8e223
0546fc9
529f5af
5f25c3b
e01cfb6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| package org.elasticsearch.index.mapper.extras; | ||
|
|
||
| import org.elasticsearch.index.mapper.OffsetDocValuesLoaderTestCase; | ||
| import org.elasticsearch.plugins.Plugin; | ||
| import org.elasticsearch.xcontent.XContentBuilder; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.Collection; | ||
|
|
||
| import static java.util.Collections.singletonList; | ||
|
|
||
| public class ScaledFloatOffsetDocValuesLoaderTests extends OffsetDocValuesLoaderTestCase { | ||
|
|
||
| @Override | ||
| protected Collection<? extends Plugin> getPlugins() { | ||
| return singletonList(new MapperExtrasPlugin()); | ||
| } | ||
|
|
||
| @Override | ||
| protected void minimalMapping(XContentBuilder b) throws IOException { | ||
| b.field("type", "scaled_float").field("scaling_factor", 10.0); | ||
| } | ||
|
|
||
| public void testOffsetArray() throws Exception { | ||
| verifyOffsets("{\"field\":[1.0,10.0,100.0,0.1,10.0,1.0,0.1,100.0]}"); | ||
| verifyOffsets("{\"field\":[10.0,null,1.0,null,5.0,null,null,6.3,1.5]}"); | ||
| } | ||
|
|
||
| @Override | ||
| protected String getFieldTypeName() { | ||
| return null; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why does this return null here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, because |
||
| } | ||
|
|
||
| @Override | ||
| protected Double randomValue() { | ||
| return randomLong() / 10.0; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| package org.elasticsearch.index.mapper.extras; | ||
|
|
||
| import com.carrotsearch.randomizedtesting.generators.RandomStrings; | ||
|
|
||
| import org.elasticsearch.index.mapper.NativeArrayIntegrationTestCase; | ||
| import org.elasticsearch.plugins.Plugin; | ||
| import org.elasticsearch.xcontent.XContentBuilder; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.Collection; | ||
|
|
||
| import static java.util.Collections.singletonList; | ||
|
|
||
| public class ScaledFloatSyntheticSourceNativeArrayIntegrationTests extends NativeArrayIntegrationTestCase { | ||
| @Override | ||
| protected Collection<Class<? extends Plugin>> getPlugins() { | ||
| return singletonList(MapperExtrasPlugin.class); | ||
| } | ||
|
|
||
| @Override | ||
| protected void minimalMapping(XContentBuilder b) throws IOException { | ||
| b.field("type", "scaled_float").field("scaling_factor", 10.0); | ||
|
||
| } | ||
|
|
||
| @Override | ||
| protected String getFieldTypeName() { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| protected Object getRandomValue() { | ||
| return randomLong() / 10.0; | ||
| } | ||
|
|
||
| @Override | ||
| protected Object getMalformedValue() { | ||
| return randomBoolean() ? RandomStrings.randomAsciiOfLength(random(), 8) : Double.POSITIVE_INFINITY; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe turn the scaling factor into a constant here?