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

Annotated text type should extend TextFieldType #49555

Merged
merged 1 commit into from
Nov 26, 2019

Conversation

romseygeek
Copy link
Contributor

@romseygeek romseygeek commented Nov 25, 2019

The annotated text mapper has a field type that currently extends StringFieldType,
which means that all the positional-related query factory methods need to be copied
over from TextFieldType. In addition, MappedFieldType.intervals() hasn't been
overridden, so you can't use intervals queries with annotated text - a major drawback,
since one of the purposes of annotated text is to be able to run positional queries against
annotations.

This commit changes the annotated text field type to extend TextFieldType instead,
adding tests to ensure that position queries work correctly.

Closes #49289

@romseygeek romseygeek added >bug :Search/Mapping Index mappings, including merging and defining field types v8.0.0 v7.6.0 labels Nov 25, 2019
@romseygeek romseygeek self-assigned this Nov 25, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/Mapping)

@markharwood
Copy link
Contributor

markharwood commented Nov 25, 2019

Had a quick look and I'm not sure about compatibility with intervals. How would an interval query work with this field value with a mixed-case annotation: [JFK](John+F+Kennedy)

I can't use a terms query in the interval and the match query forces lowercase because that's what the host text field uses:

{
"intervals" : {
  "headline" : {
	"all_of" : {
	  "ordered" : true,
	  "intervals" : [
		{
		  "match" : {
			"query" : "he visited",
			"max_gaps" : 0,
			"ordered" : true
		  }
		},
		{
		  "any_of" : {
			"intervals" : [
			  { "match" : { "query" : "John F Kennedy" } },
                               { "match" : { "query" : "Marilyn Monroe" } }
			]
		  }
		}
	  ]
	}
  }
}

If that's opening a can of worms maybe we can separate the "make interval queries work with annotations" into a different PR.

Copy link
Contributor

@jimczi jimczi left a comment

Choose a reason for hiding this comment

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

LGTM

If that's opening a can of worms maybe we can separate the "make interval queries work with annotations" into a different PR.

+1 to address this in a follow up.

@romseygeek
Copy link
Contributor Author

@markharwood you can specify an analyzer for an intervals match source, so if you have mixed-case or multiple-term annotations then you can query for it with analyzer: keyword

Copy link
Contributor

@markharwood markharwood left a comment

Choose a reason for hiding this comment

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

LGTM - thanks, @romseygeek

@romseygeek romseygeek merged commit 563b273 into elastic:master Nov 26, 2019
@romseygeek romseygeek deleted the ann-text-intervals branch November 26, 2019 16:51
romseygeek added a commit that referenced this pull request Nov 26, 2019
The annotated text mapper has a field type that currently extends StringFieldType,
which means that all the positional-related query factory methods need to be copied
over from TextFieldType. In addition, MappedFieldType.intervals() hasn't been
overridden, so you can't use intervals queries with annotated text - a major drawback,
since one of the purposes of annotated text is to be able to run positional queries against
annotations.

This commit changes the annotated text field type to extend TextFieldType instead,
adding tests to ensure that position queries work correctly.

Closes #49289
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search/Mapping Index mappings, including merging and defining field types v7.6.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Interval Query should work with Annotated Text Plugin
5 participants