-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Make semantic text part of the text family #119792
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3b8a9ab
Make semantic text part of the text family
Mikep86 e037bba
Update error message
Mikep86 8a0483e
Fix ESQL tests
ioanatia 4c97243
Update docs/changelog/119792.yaml
Mikep86 18eace6
Update changelog
Mikep86 4deaf69
Fix semantic text YAML tests
Mikep86 164cbbc
Merge branch 'main' into semantic-text_text-family-type
Mikep86 258e286
Fix ES|QL tests
ioanatia 629d961
Merge branch 'main' into semantic-text_text-family-type
elasticmachine 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 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: 119792 | ||
summary: Make semantic text part of the text family | ||
area: Search | ||
type: enhancement | ||
issues: [] |
This file contains 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 |
---|---|---|
|
@@ -43,6 +43,9 @@ | |
import org.elasticsearch.index.mapper.PlaceHolderFieldMapper; | ||
import org.elasticsearch.index.mapper.TextFieldMapper; | ||
import org.elasticsearch.index.mapper.TextSearchInfo; | ||
import org.elasticsearch.index.query.MatchBoolPrefixQueryBuilder; | ||
import org.elasticsearch.index.query.MatchPhrasePrefixQueryBuilder; | ||
import org.elasticsearch.index.query.MatchPhraseQueryBuilder; | ||
import org.elasticsearch.index.query.SearchExecutionContext; | ||
import org.elasticsearch.index.query.ZeroTermsQueryOption; | ||
import org.elasticsearch.lucene.analysis.miscellaneous.DisableGraphAttribute; | ||
|
@@ -63,24 +66,26 @@ public enum Type implements Writeable { | |
/** | ||
* The text is analyzed and terms are added to a boolean query. | ||
*/ | ||
BOOLEAN(0), | ||
BOOLEAN(0, org.elasticsearch.index.query.MatchQueryBuilder.NAME), | ||
/** | ||
* The text is analyzed and used as a phrase query. | ||
*/ | ||
PHRASE(1), | ||
PHRASE(1, MatchPhraseQueryBuilder.NAME), | ||
/** | ||
* The text is analyzed and used in a phrase query, with the last term acting as a prefix. | ||
*/ | ||
PHRASE_PREFIX(2), | ||
PHRASE_PREFIX(2, MatchPhrasePrefixQueryBuilder.NAME), | ||
/** | ||
* The text is analyzed, terms are added to a boolean query with the last term acting as a prefix. | ||
*/ | ||
BOOLEAN_PREFIX(3); | ||
BOOLEAN_PREFIX(3, MatchBoolPrefixQueryBuilder.NAME); | ||
|
||
private final int ordinal; | ||
private final String queryName; | ||
|
||
Type(int ordinal) { | ||
Type(int ordinal, String queryName) { | ||
this.ordinal = ordinal; | ||
this.queryName = queryName; | ||
} | ||
|
||
public static Type readFromStream(StreamInput in) throws IOException { | ||
|
@@ -93,6 +98,10 @@ public static Type readFromStream(StreamInput in) throws IOException { | |
throw new ElasticsearchException("unknown serialized type [" + ord + "]"); | ||
} | ||
|
||
public String getQueryName() { | ||
return queryName; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeVInt(this.ordinal); | ||
|
@@ -207,11 +216,23 @@ public Query parse(Type type, String fieldName, Object value) throws IOException | |
IllegalArgumentException iae; | ||
if (fieldType instanceof PlaceHolderFieldMapper.PlaceHolderFieldType) { | ||
iae = new IllegalArgumentException( | ||
"Field [" + fieldType.name() + "] of type [" + fieldType.typeName() + "] in legacy index does not support match queries" | ||
"Field [" | ||
+ fieldType.name() | ||
+ "] of type [" | ||
+ fieldType.typeName() | ||
+ "] in legacy index does not support " | ||
+ type.getQueryName() | ||
+ " queries" | ||
); | ||
} else { | ||
iae = new IllegalArgumentException( | ||
"Field [" + fieldType.name() + "] of type [" + fieldType.typeName() + "] does not support match queries" | ||
"Field [" | ||
+ fieldType.name() | ||
+ "] of type [" | ||
+ fieldType.typeName() | ||
+ "] does not support " | ||
+ type.getQueryName() | ||
+ " queries" | ||
Comment on lines
-214
to
+235
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 changed this error message because it is propagated through to Kibana when attempting to run a |
||
); | ||
} | ||
if (lenient) { | ||
|
This file contains 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 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 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 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.
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.
Nitpick: Can we clean up imports a bit here, so we don't reference the full class name here?
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.
Can't, there's an inner class called
MatchQueryBuilder
inMatchQueryParser
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 break it out into a variable then?