Skip to content

Allow different data types for category in Context suggester#23491

Merged
rjernst merged 5 commits intoelastic:masterfrom
nilabhsagar:issue22358
Apr 13, 2017
Merged

Allow different data types for category in Context suggester#23491
rjernst merged 5 commits intoelastic:masterfrom
nilabhsagar:issue22358

Conversation

@nilabhsagar
Copy link
Copy Markdown
Contributor

@nilabhsagar nilabhsagar commented Mar 6, 2017

The "category" in context suggester could be String, Number or Boolean. However with the changes in version 5 this is failing and only accepting String. This will have problem for existing users of Elasticsearch if they choose to migrate to higher version; as their existing Mapping and query will fail as mentioned in a bug #22358

This PR fixes the above mentioned issue and allows user to migrate seamlessly.

Note: Providing the NULL value for a category at index and query time will throw an exception.

Closes #22358

@elasticmachine
Copy link
Copy Markdown
Collaborator

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@nilabhsagar nilabhsagar changed the title Fix for issue #22358 Fixes context suggestion with Boolean contexts:illegal_argument_exception #22358 Mar 14, 2017
@nilabhsagar
Copy link
Copy Markdown
Contributor Author

@areek Request you to look at this fix.

@nilabhsagar
Copy link
Copy Markdown
Contributor Author

Hi Requesting some one from Elasticsearch to verify this fix.

Copy link
Copy Markdown
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

Sorry for the long delay. I left some comments. This also needs tests.

final Set<CharSequence> contexts = new HashSet<>();
Token token = parser.currentToken();
if (token == Token.VALUE_STRING) {
if (token == Token.VALUE_NULL) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think we should be adding support for null here. It should remain an error.

if (token == Token.VALUE_STRING) {
if (token == Token.VALUE_STRING || token == Token.VALUE_NUMBER || token == Token.VALUE_BOOLEAN) {
contexts.add(parser.text());
} else if (token == Token.VALUE_NULL) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ditto here; this should not be added.

@rjernst rjernst added >enhancement :Search Relevance/Suggesters "Did you mean" and suggestions as you type labels Apr 11, 2017
@nilabhsagar
Copy link
Copy Markdown
Contributor Author

@rjernst Thanks for the review, I have incorporated the changes as suggested by you.

Copy link
Copy Markdown
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

Thank you for the tests and changes! One more request for the tests, and could you also please update the PR title and description to explain what is changing.

.endArray()
.endObject()
.bytes());
} catch(MapperParsingException e) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can use expectThrows(MapperParsingException.class, () -> { /* code that throws */});, then check the message on the returned exception.

@rjernst
Copy link
Copy Markdown
Member

rjernst commented Apr 11, 2017

@elasticmachine please test this

@nilabhsagar nilabhsagar changed the title Fixes context suggestion with Boolean contexts:illegal_argument_exception #22358 Allow different data types for category in Context suggester Apr 12, 2017
@nilabhsagar
Copy link
Copy Markdown
Contributor Author

@rjernst as suggested all changes are done. Please verify.

@rjernst rjernst merged commit ec42197 into elastic:master Apr 13, 2017
@rjernst
Copy link
Copy Markdown
Member

rjernst commented Apr 13, 2017

Thanks @nilabhsagar

rjernst pushed a commit that referenced this pull request Apr 13, 2017
The "category" in context suggester could be String, Number or Boolean. However with the changes in version 5 this is failing and only accepting String. This will have problem for existing users of Elasticsearch if they choose to migrate to higher version; as their existing Mapping and query will fail as mentioned in a bug #22358

This PR fixes the above mentioned issue and allows user to migrate seamlessly.

Closes #22358
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Apr 13, 2017
* master: (41 commits)
  Remove awaits fix from evil JNA native tests
  Correct handling of default and array settings
  Build: Switch jna dependency to an elastic version (elastic#24081)
  fix CategoryContextMappingTests compilation bugs
  testConcurrentGetAndSetOnPrimary - fix a race condition between indexing and updating value map
  Allow different data types for category in Context suggester (elastic#23491)
  Restrict build info loading to ES jar, not any jar (elastic#24049)
  Remove more hidden file leniency from plugins
  Register error listener in evil logger tests
  Detect using logging before configuration
  [DOCS] Added note about Elastic Cloud to improve 'elastic aws' SERP results.
  Add version constant for 5.5 (elastic#24075)
  Add unit tests for NestedAggregator (elastic#24054)
  Add more debugging information to rethrottles
  Tests: Use random analyzer only on string fields in Match/MultiMatchBuilderTests
  Cleanup outdated comments for fixing up pom dependencies (elastic#24056)
  S3 Repository: Eagerly load static settings (elastic#23910)
  Reject duplicate settings on the command line
  Wildcard cluster names for cross cluster search (elastic#23985)
  Update scripts/security docs for sandboxed world (elastic#23977)
  ...
@nilabhsagar
Copy link
Copy Markdown
Contributor Author

Thanks @rjernst

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

context suggestion with Boolean contexts:illegal_argument_exception

3 participants