-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Flag in _field_caps to return only fields with values in index #103651
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
Merged
Merged
Changes from all commits
Commits
Show all changes
122 commits
Select commit
Hold shift + click to select a range
c8af341
add has_value to field_caps response
piergm e17fe2c
Merge branch 'elastic:main' into field_caps-has_value
piergm feccdc7
working prototype
piergm 5ad8b99
move map to shard instead of index, adds queryparam
piergm ed3c3c6
rename query param to include_fields_with_no_value
piergm 45d892c
code clean
piergm 21061bb
include_fields_with_no_value defaults to true
piergm e92e9dc
defaults in tests
piergm 838ebbd
defaults in tests
piergm f5bfd31
Update docs/changelog/103651.yaml
piergm 4fc26d6
Merge branch 'main' into field_caps-has_value
piergm f886135
closing readers
piergm 47af25e
small refactor
piergm 683459f
move listener afterIndexShardStarted and close reader
piergm 597f5a8
closes just searcher
piergm 752d31e
updated tests
piergm a21d6fa
spotless
piergm c15dd78
added 1 to number of refresh of FrozenIndex test
piergm d6e9e65
updated docs and added tests
piergm 8d1fa0a
Merge branch 'main' into field_caps-has_value
piergm 58ab703
iter
piergm c19d573
iter
piergm 76e5060
moved afterShardCreated to afterIndexCreated
piergm d53c56d
CI
piergm 60d3731
Merge branch 'elastic:main' into field_caps-has_value
piergm 322d65d
iter
piergm 6e90f58
updated bwc tests
piergm 5a91222
spotless
piergm 4f4ef65
spotless
piergm 8f37313
Merge branch 'main' into field_caps-has_value
piergm 5add85b
alias are now returned if original field has value
piergm c1abe2b
mock IndexShard in tests
piergm d2332bd
reworked field caps request and response tests
piergm a500abd
removed todo
piergm 62759c6
spotless
piergm 39821d9
first set of tests
piergm 7999611
set instead of map
piergm 9c97ee5
iter
piergm 734a72a
iter
piergm 6da0369
iter
piergm ca6893a
more iter
piergm b6a7dee
Merge branch 'main' into field_caps-has_value
piergm db70f45
spotless
piergm e6c528d
updated tests
piergm cb2669b
iter
piergm a16e6ba
Merge branch 'main' into field_caps-has_value
piergm cc4edd3
correct tests resolve wrong merge of indexResponse
piergm 75bea68
updated docs
piergm 10ec350
add tests for nested fields
piergm 8f848b8
add tests for obj fields
piergm 774a21a
Merge branch 'elastic:main' into field_caps-has_value
piergm fc4c198
iter + tests
piergm b860d7e
Merge branch 'main' into field_caps-has_value
piergm 7d17ca3
propagate flag in remote requests + comments
piergm 9713967
Merge branch 'main' into field_caps-has_value
piergm c22377d
Update docs/reference/search/field-caps.asciidoc
piergm fdfbe3b
Merge branch 'main' into field_caps-has_value
piergm 18e987b
iter
piergm 31706c2
for loops instead of lambdas
piergm 09bc9a6
Map instead of Set to leverage putIfAbsent for perf
piergm ed68390
Merge branch 'main' into field_caps-has_value
piergm 49c6d87
handle updated docs
piergm 341cd7c
lazy load non-empty fields
piergm 8f8e623
revert frozenIndexTests due to lazy loading
piergm 9d1fd93
sys prop to diable field has value feature
piergm 25c906f
if feature disable use legacy hash
piergm 7c768c8
moved field-has-value logic after refresh
piergm da717bd
Merge branch 'main' into field_caps-has_value
piergm 578677d
Merge branch 'elastic:main' into field_caps-has_value
piergm 72c972e
Update docs/reference/search/field-caps.asciidoc
piergm 001e696
Merge branch 'main' into field_caps-has_value
piergm 513083e
test for feature_rank
piergm da846a6
index shard to update field has value after refresh
piergm 9547296
removed rank_feature tests from 'server'
piergm 653a8f0
rank_feature tests in 'extras'
piergm 50d8a8f
move fieldHasValue in MappedFieldType
piergm 0cc060c
Merge branch 'main' into field_caps-has_value
piergm 8fa1d0d
iter
piergm 06b1641
iter
piergm f30daaf
javadoc + cleaning
piergm f290e71
fixing after restart issues
piergm e1f86ea
Merge branch 'main' into field_caps-has_value
piergm 3ab7529
renamed include_fields_with_no_value to include_empty_fields + iter
piergm a5c269d
Merge branch 'elastic:main' into field_caps-has_value
piergm 18c4353
keeping list of FieldInfos instead of merging them since they are alr…
piergm 5a75987
rank_feature fieldType unitTests
piergm 1bf7d39
RankFeatureMetaFieldType unitTests
piergm f5ae465
ScriptFieldTypes unitTests
piergm 54edf53
ConstantFieldTypes unitTests
piergm 09e6d92
MappedFieldTypeTest
piergm 2f0ac60
iter
piergm 8fa1b6e
renamed tests
piergm fa390e4
merging fieldInfos
piergm 6f3ed17
rename
piergm 1339277
removed tests covered by unit tests
piergm 44904c8
basic yaml test
piergm 29b93cd
iter
piergm 8156756
corrected tests
piergm a7b64c4
yaml tests
piergm fe5245d
Merge branch 'main' into field_caps-has_value
piergm 7391105
Merge branch 'elastic:main' into field_caps-has_value
piergm 482c11f
yaml tests
piergm d9cd4f8
I've found restSpec
piergm 9498dce
Merge branch 'main' into field_caps-has_value
piergm 57de9f7
test
piergm 8868e4d
iter
piergm f2db1cd
tests
piergm c0f453d
renamed test to standard
piergm 5cef376
moved unmapped field to yml test
piergm daf034f
multi-cluster test
piergm 5c8ea58
tested default behaviour in FieldTypeTestCase and overwritten when ne…
piergm 4555a0e
removed old test class
piergm be7483f
standardizing tests
piergm 058c6c8
Merge branch 'elastic:main' into field_caps-has_value
piergm b1aeb86
multi cluster tests
piergm 4789d78
maybe fixed multi-cluster
piergm 2e8f7b7
Merge branch 'main' into field_caps-has_value
piergm 8115dcd
iter
piergm a4e2d8d
removed empty spaces
piergm b6d667b
Merge branch 'elastic:main' into field_caps-has_value
piergm 4a2d503
iter
piergm be4e91a
Merge branch 'main' into field_caps-has_value
piergm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pr: 103651 | ||
summary: Flag in `_field_caps` to return only fields with values in index | ||
area: Search | ||
type: enhancement | ||
issues: [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
...extras/src/test/java/org/elasticsearch/index/mapper/extras/FieldCapsRankFeatureTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
* 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 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 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.index.mapper.extras; | ||
|
||
import org.elasticsearch.action.fieldcaps.FieldCapabilities; | ||
import org.elasticsearch.action.fieldcaps.FieldCapabilitiesResponse; | ||
import org.elasticsearch.action.support.ActiveShardCount; | ||
import org.elasticsearch.plugins.Plugin; | ||
import org.elasticsearch.test.ESIntegTestCase; | ||
import org.hamcrest.Matchers; | ||
import org.junit.Before; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; | ||
|
||
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST) | ||
public class FieldCapsRankFeatureTests extends ESIntegTestCase { | ||
private final String INDEX = "index-1"; | ||
|
||
@Override | ||
protected Collection<Class<? extends Plugin>> nodePlugins() { | ||
var plugins = new ArrayList<>(super.nodePlugins()); | ||
plugins.add(MapperExtrasPlugin.class); | ||
return plugins; | ||
} | ||
|
||
@Before | ||
public void setUpIndices() { | ||
assertAcked( | ||
prepareCreate(INDEX).setWaitForActiveShards(ActiveShardCount.ALL) | ||
.setSettings(indexSettings()) | ||
.setMapping("fooRank", "type=rank_feature", "barRank", "type=rank_feature") | ||
); | ||
} | ||
|
||
public void testRankFeatureInIndex() { | ||
FieldCapabilitiesResponse response = client().prepareFieldCaps(INDEX).setFields("*").setincludeEmptyFields(false).get(); | ||
assertFalse(response.get().containsKey("fooRank")); | ||
assertFalse(response.get().containsKey("barRank")); | ||
prepareIndex(INDEX).setSource("fooRank", 8).setSource("barRank", 8).get(); | ||
refresh(INDEX); | ||
|
||
response = client().prepareFieldCaps(INDEX).setFields("*").setincludeEmptyFields(false).get(); | ||
assertEquals(1, response.getIndices().length); | ||
assertEquals(response.getIndices()[0], INDEX); | ||
assertThat(response.get(), Matchers.hasKey("fooRank")); | ||
// Check the capabilities for the 'fooRank' field. | ||
Map<String, FieldCapabilities> fooRankField = response.getField("fooRank"); | ||
assertEquals(1, fooRankField.size()); | ||
assertThat(fooRankField, Matchers.hasKey("rank_feature")); | ||
assertEquals( | ||
new FieldCapabilities("fooRank", "rank_feature", false, true, false, null, null, null, Collections.emptyMap()), | ||
fooRankField.get("rank_feature") | ||
); | ||
} | ||
|
||
public void testRankFeatureInIndexAfterRestart() throws Exception { | ||
prepareIndex(INDEX).setSource("fooRank", 8).get(); | ||
internalCluster().fullRestart(); | ||
ensureGreen(INDEX); | ||
|
||
FieldCapabilitiesResponse response = client().prepareFieldCaps(INDEX).setFields("*").setincludeEmptyFields(false).get(); | ||
|
||
assertEquals(1, response.getIndices().length); | ||
assertEquals(response.getIndices()[0], INDEX); | ||
assertThat(response.get(), Matchers.hasKey("fooRank")); | ||
// Check the capabilities for the 'fooRank' field. | ||
Map<String, FieldCapabilities> fooRankField = response.getField("fooRank"); | ||
assertEquals(1, fooRankField.size()); | ||
assertThat(fooRankField, Matchers.hasKey("rank_feature")); | ||
assertEquals( | ||
new FieldCapabilities("fooRank", "rank_feature", false, true, false, null, null, null, Collections.emptyMap()), | ||
fooRankField.get("rank_feature") | ||
); | ||
} | ||
|
||
public void testAllRankFeatureReturnedIfOneIsPresent() { | ||
prepareIndex(INDEX).setSource("fooRank", 8).get(); | ||
refresh(INDEX); | ||
|
||
FieldCapabilitiesResponse response = client().prepareFieldCaps(INDEX).setFields("*").setincludeEmptyFields(false).get(); | ||
|
||
assertEquals(1, response.getIndices().length); | ||
assertEquals(response.getIndices()[0], INDEX); | ||
assertThat(response.get(), Matchers.hasKey("fooRank")); | ||
// Check the capabilities for the 'fooRank' field. | ||
Map<String, FieldCapabilities> fooRankField = response.getField("fooRank"); | ||
assertEquals(1, fooRankField.size()); | ||
assertThat(fooRankField, Matchers.hasKey("rank_feature")); | ||
assertEquals( | ||
new FieldCapabilities("fooRank", "rank_feature", false, true, false, null, null, null, Collections.emptyMap()), | ||
fooRankField.get("rank_feature") | ||
); | ||
assertThat(response.get(), Matchers.hasKey("barRank")); | ||
// Check the capabilities for the 'barRank' field. | ||
Map<String, FieldCapabilities> barRankField = response.getField("barRank"); | ||
assertEquals(1, barRankField.size()); | ||
assertThat(barRankField, Matchers.hasKey("rank_feature")); | ||
assertEquals( | ||
new FieldCapabilities("barRank", "rank_feature", false, true, false, null, null, null, Collections.emptyMap()), | ||
barRankField.get("rank_feature") | ||
); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.