-
Notifications
You must be signed in to change notification settings - Fork 25.3k
New terms_enum API for discovering terms in the index. #66452
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
31 commits
Select commit
Hold shift + click to select a range
9ffbb03
A TermsEnum API for discovering terms in the index.
markharwood b95cf81
Added HLRC support and related integration test
markharwood ab826b4
Added client classes for HLRC.
markharwood 7a5e654
License fix
markharwood 93dfe30
Remove HLRC code for now - requires less-than-ideal package names whi…
markharwood 58bbf41
Return empty arrays when no results rather than no `terms` property a…
markharwood 7fb781d
Fix bundling of shardIds for nodes, add success/fail accounting of nu…
markharwood 4e9da39
Type fixes
markharwood cac1bb3
Types warning
markharwood 810d638
Removed hot/warm tier tests (in anticipation of new queryable _tier f…
markharwood 156302f
Move rest-api-spec and related YML test to new standard home for this…
markharwood 62af758
Unused import
markharwood 03f79de
Move test to xpack
markharwood 53e12cd
Return early on network thread if can’t match any shards.
markharwood b36f477
Removed sort by popularity option
markharwood 3b1b6d9
Unused import
markharwood 5250cc7
Addressing some review comments (thanks Jim/Adrien!)
markharwood 3288641
Docs tidy up
markharwood 2c00968
Provide full stack traces for errors, change TODO comment
markharwood 6a68b70
Move location of YAML test - was causing errors when seated alongside…
markharwood 1fe0a11
Security enhancement - allow access where DLS rewrites to match_all. …
markharwood 2f59860
Remove acquisition of searcher from security check code
markharwood 4c38b78
Changed termenum to termsenum. REST endpoint is now _terms_enum
markharwood c40a0db
Checkstyle fix
markharwood 6b9f41c
Addressing review comments - formatting, thread pool choices and more
markharwood 814e45e
Oops. Thought I’d resolved this review comment but hadn’t
markharwood 9897518
Changed timeout setting to a TimeValue
markharwood 2cb91df
Checkstyle fix
markharwood 6d55f99
In flattened fields make only the value (not the field name) subject …
markharwood cf70053
Moved initialisation of data node timing of request from NodeTermsEnu…
markharwood 22312cf
Remove outdated TODOs
markharwood 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,97 @@ | ||
[[search-terms-enum]] | ||
=== Terms enum API | ||
|
||
The terms enum API can be used to discover terms in the index that match | ||
a partial string. This is used for auto-complete: | ||
|
||
[source,console] | ||
-------------------------------------------------- | ||
POST stackoverflow/_terms_enum | ||
{ | ||
"field" : "tags", | ||
"string" : "kiba" | ||
} | ||
-------------------------------------------------- | ||
// TEST[setup:stackoverflow] | ||
|
||
|
||
The API returns the following response: | ||
|
||
[source,console-result] | ||
-------------------------------------------------- | ||
{ | ||
"_shards": { | ||
"total": 1, | ||
"successful": 1, | ||
"failed": 0 | ||
}, | ||
"terms": [ | ||
"kibana" | ||
], | ||
"complete" : true | ||
} | ||
-------------------------------------------------- | ||
|
||
The "complete" flag is false if time or space constraints were met and the | ||
set of terms examined was not the full set of available values. | ||
|
||
[[search-terms-enum-api-request]] | ||
==== {api-request-title} | ||
|
||
`GET /<target>/_terms_enum` | ||
|
||
|
||
[[search-terms-enum-api-desc]] | ||
==== {api-description-title} | ||
|
||
The termsenum API can be used to discover terms in the index that begin with the provided | ||
string. It is designed for low-latency look-ups used in auto-complete scenarios. | ||
|
||
|
||
[[search-terms-enum-api-path-params]] | ||
==== {api-path-parms-title} | ||
|
||
`<target>`:: | ||
(Mandatory, string) | ||
Comma-separated list of data streams, indices, and index aliases to search. | ||
Wildcard (`*`) expressions are supported. | ||
+ | ||
To search all data streams or indices in a cluster, omit this parameter or use | ||
`_all` or `*`. | ||
|
||
[[search-terms-enum-api-request-body]] | ||
==== {api-request-body-title} | ||
|
||
[[terms-enum-field-param]] | ||
`field`:: | ||
(Mandatory, string) | ||
Which field to match | ||
|
||
[[terms-enum-string-param]] | ||
`string`:: | ||
(Mandatory, string) | ||
The string to match at the start of indexed terms | ||
|
||
[[terms-enum-size-param]] | ||
`size`:: | ||
(Optional, integer) | ||
How many matching terms to return. Defaults to 10 | ||
|
||
[[terms-enum-timeout-param]] | ||
`timeout`:: | ||
(Optional, <<time-units,time value>>) | ||
The maximum length of time to spend collecting results. Defaults to "1s" (one second). | ||
If the timeout is exceeded the `complete` flag set to false in the response and the results may | ||
be partial or empty. | ||
|
||
[[terms-enum-case_insensitive-param]] | ||
`case_insensitive`:: | ||
(Optional, boolean) | ||
When true the provided search string is matched against index terms without case sensitivity. | ||
Defaults to false. | ||
|
||
[[terms-enum-index_filter-param]] | ||
`index_filter`:: | ||
(Optional, <<query-dsl,query object>> Allows to filter an index shard if the provided | ||
query rewrites to `match_none`. | ||
|
35 changes: 35 additions & 0 deletions
35
rest-api-spec/src/main/resources/rest-api-spec/api/termsenum.json
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,35 @@ | ||
{ | ||
"termsenum":{ | ||
"documentation":{ | ||
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/terms-enum.html", | ||
"description": "The terms enum API can be used to discover terms in the index that begin with the provided string. It is designed for low-latency look-ups used in auto-complete scenarios." | ||
}, | ||
"stability":"beta", | ||
"visibility":"public", | ||
"headers":{ | ||
"accept": [ "application/json"], | ||
"content_type": ["application/json"] | ||
}, | ||
"url":{ | ||
"paths":[ | ||
{ | ||
"path": "/{index}/_terms_enum", | ||
"methods": [ | ||
"GET", | ||
"POST" | ||
], | ||
"parts": { | ||
"index": { | ||
"type": "list", | ||
"description": "A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"params":{}, | ||
"body":{ | ||
"description":"field name, string which is the prefix expected in matching terms, timeout and size for max number of results" | ||
} | ||
} | ||
} |
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.