Skip to content
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

Completion mapping type throws a misleading error on null value #6926

Closed
wants to merge 1 commit into from

Conversation

areek
Copy link
Contributor

@areek areek commented Jul 18, 2014

When the mapper service gets a null value for a field, it tries to parse it with the mapper of any previously seen field, if that mapper happens to be CompletionMapper, it throws an error, as it only accepts certain fields.

Closes #6399

@areek areek added the review label Jul 18, 2014
@@ -533,7 +534,7 @@ public void parse(ParseContext context) throws IOException {
private void serializeNullValue(ParseContext context, String lastFieldName) throws IOException {
// we can only handle null values if we have mappings for them
Mapper mapper = mappers.get(lastFieldName);
if (mapper != null) {
if (mapper != null && !(mapper instanceof CompletionFieldMapper)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we do instance checks here or have something similar to AbstractFieldMapper.isSortable() to decide if a mapper supports a certain feature, is isSupportingNullValue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spinscale Thanks for the suggestion, I think isSupportingNullValue is a cleaner way to do this. Changed as suggested.

@s1monw s1monw removed the review label Jul 22, 2014
@areek
Copy link
Contributor Author

areek commented Jul 25, 2014

Updated PR: Now having a null value for a completion field will throw an exception.

@@ -286,6 +286,8 @@ public static Loading parse(String loading, Loading defaultValue) {

boolean isSortable();

boolean isSupportingNullValue();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or shorter: supportsNullValue? (though I might be completely wrong as my English is what it is...)

@jpountz
Copy link
Contributor

jpountz commented Aug 1, 2014

LGTM

@jpountz jpountz removed the review label Aug 1, 2014
@areek
Copy link
Contributor Author

areek commented Aug 1, 2014

@jpountz thanks for the review, I have changed the name to supportsNullValue (I like it better). I will commit this shortly if there are not objections.

@areek areek closed this Aug 1, 2014
@clintongormley clintongormley changed the title Completion mapping type throws a misleading error on null value Suggesters: Completion mapping type throws a misleading error on null value Sep 10, 2014
@clintongormley clintongormley added the :Search/Suggesters "Did you mean" and suggestions as you type label Jun 7, 2015
@clintongormley clintongormley changed the title Suggesters: Completion mapping type throws a misleading error on null value Completion mapping type throws a misleading error on null value Jun 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search/Suggesters "Did you mean" and suggestions as you type v1.4.0.Beta1 v2.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Completion mapping type throws a misleading error on null value
5 participants