-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Make indices APIs consistent #4071
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
Comments
[...] _I think all should be an acceptable alias for * for all of them I agree. Just for completeness: we also currently have the
and also for warmers:
For mappings, delete is:
For settings there is none and would probably not make sense to have that. |
So we have I vote for
|
After discussion here is what I will implement:
For
|
Just like to give my £0.02 few years ago i was designing REST API's and was following some webinars by a company who design api's ( http://www.youtube.com/apigee ) and following in a few nice discussions on the google groups ( https://groups.google.com/forum/#!forum/api-craft ) One of those items was the singular/plural discussion and at the end of it the 'pragmatic' approach would be to use only plural names. An other thing is the ordering, by allowing different methods it can become confusing again. Cheers. |
Forgot to address the single or multiple items in an endpoint call.
this makes things consistent across the board and avoid having different endpoints for pretty much the same thing. |
In principle I agree to the plural only. However, since some APIs are already singular, it might be good have plural and singular as synonyms? There is several issues we would like to fix:
Assuming that we agree on making plural and singular synonyms, this would require the following list of changes:
|
Here's a proposed roadmap of what should be done for RC1, and what can follow later: PUT (singular)
Also support:
Where:
POST (plural)
Also support:
Where:
Should we also support this?
Probably not as we can't delete aliases at the same time. GET (singular or plural)
Also support:
Where:
Missing types/warmers/aliases/settings should return empty objects, not throw 404s DELETE (singular or plural)
Also support:
Where:
If no matching types/warmers/aliases/settings found, throw 404. |
The output from GET requests should have the following format:
In other words:
For example:
If
|
Single type can now be added with `[PUT|POST] {index|_all|*|regex|blank}/[_mapping|_mappings]/type` and `[PUT|POST] {index|_all|*|regex|blank}/type/[_mapping|_mappings]` see roadmap at issue elastic#4071
PUT with a single warmer can now be done with `[PUT|POST] {index|_all|*|prefix*|blank}/{type|_all|*|prefix*|blank}/[_warmer|_warmers]/warmer_name` see roadmap issue elastic#4071
Single alias can now be PUT with `[PUT|POST] {index|_all|*|prefix*|blank}/[_alias|_aliases]/alias` see roadmap in issue elastic#4071
Several mappings can be deleted at once by defining several indices and types with `[DELETE] /{index}/{type}` `[DELETE] /{index}/{type}/_mapping` `[DELETE] /{index}/_mapping/{type}` where `index= * | _all | glob pattern | name1, name2, …` `type= * | _all | glob pattern | name1, name2, …` Alternatively, the keyword `_mapings` can be used. see roadmap issue elastic#4071
See issue elastic#4071 PUT options for _mapping: Single type can now be added with `[PUT|POST] {index|_all|*|regex|blank}/[_mapping|_mappings]/type` and `[PUT|POST] {index|_all|*|regex|blank}/type/[_mapping|_mappings]` PUT options for _warmer: PUT with a single warmer can now be done with `[PUT|POST] {index|_all|*|prefix*|blank}/{type|_all|*|prefix*|blank}/[_warmer|_warmers]/warmer_name` PUT options for _alias: Single alias can now be PUT with `[PUT|POST] {index|_all|*|prefix*|blank}/[_alias|_aliases]/alias` DELETE options _mapping: Several mappings can be deleted at once by defining several indices and types with `[DELETE] /{index}/{type}` `[DELETE] /{index}/{type}/_mapping` `[DELETE] /{index}/_mapping/{type}` where `index= * | _all | glob pattern | name1, name2, …` `type= * | _all | glob pattern | name1, name2, …` Alternatively, the keyword `_mapings` can be used. DELETE options for _warmer: Several warmers can be deleted at once by defining several indices and names with `[DELETE] /{index}/_warmer/{type}` where `index= * | _all | glob pattern | name1, name2, …` `type= * | _all | glob pattern | name1, name2, …` Alternatively, the keyword `_warmers` can be used. DELETE options for _alias: Several aliases can be deleted at once by defining several indices and names with `[DELETE] /{index}/_alias/{type}` where `index= * | _all | glob pattern | name1, name2, …` `type= * | _all | glob pattern | name1, name2, …` Alternatively, the keyword `_aliases` can be used.
See issue #4071 PUT options for _mapping: Single type can now be added with `[PUT|POST] {index|_all|*|regex|blank}/[_mapping|_mappings]/type` and `[PUT|POST] {index|_all|*|regex|blank}/type/[_mapping|_mappings]` PUT options for _warmer: PUT with a single warmer can now be done with `[PUT|POST] {index|_all|*|prefix*|blank}/{type|_all|*|prefix*|blank}/[_warmer|_warmers]/warmer_name` PUT options for _alias: Single alias can now be PUT with `[PUT|POST] {index|_all|*|prefix*|blank}/[_alias|_aliases]/alias` DELETE options _mapping: Several mappings can be deleted at once by defining several indices and types with `[DELETE] /{index}/{type}` `[DELETE] /{index}/{type}/_mapping` `[DELETE] /{index}/_mapping/{type}` where `index= * | _all | glob pattern | name1, name2, …` `type= * | _all | glob pattern | name1, name2, …` Alternatively, the keyword `_mapings` can be used. DELETE options for _warmer: Several warmers can be deleted at once by defining several indices and names with `[DELETE] /{index}/_warmer/{type}` where `index= * | _all | glob pattern | name1, name2, …` `type= * | _all | glob pattern | name1, name2, …` Alternatively, the keyword `_warmers` can be used. DELETE options for _alias: Several aliases can be deleted at once by defining several indices and names with `[DELETE] /{index}/_alias/{type}` where `index= * | _all | glob pattern | name1, name2, …` `type= * | _all | glob pattern | name1, name2, …` Alternatively, the keyword `_aliases` can be used.
Added support for /{index}/_mappings/{type} and /{index}/_mapping/{type} Also added spec tests Relates elastic#4071
Added support for /{index}/_warmers/{type} Also added spec and integration tests to support wildcards and _all in warmer names Relates elastic#4071
Added support for /{index}/_aliases/{name} Also added spec tests to support wildcards and _all in get alias API Relates elastic#4071
Added support for /{index}/_setting/{name} Also added spec tests to support wildcards in setting name Reverted parts of elastic@0973b28 to fit into consistent API strategy Relates elastic#4071
If an index exists, but a single warmer/setting/alias/type is missing return an empty JSON instead of an 404 Relates elastic#4071
…return the concrete index Relates elastic#4071
* Made GET mappings consistent, supporting * /{index}/_mappings/{type} * /{index}/_mapping/{type} * /_mapping/{type} * Added "mappings" in the JSON response to align it with other responses * Made GET warmers consistent, support /{index}/_warmers/{type} and /_warmer, /_warner/{name} as well as wildcards and _all notation * Made GET aliases consistent, support /{index}/_aliases/{name} and /_alias, /_aliases/{name} as well as wildcards and _all notation * Made GET settings consistent, added /{index}/_setting/{name}, /_settings/{name} as well as supportings wildcards in settings name * Returning empty JSON instead of a 404, if a specific warmer/ setting/alias/type is missing * Added a ton of spec tests for all of the above * Added a couple of more integration tests for several features Relates elastic#4071
The get field mapping API now includes a mappings element after the index in its JSON Added more consistent endpoint /{index}/_mapping/{type}/field/{fields} and added endpoint /_mapping/{type}/field/{fields} which are also used in tests Added rest spec tests for wildcards and _all Relates elastic#4071 NOTE: This is not yet complete for 1.0. We need to return an empty JSON document instead of a 404 if the field of an existing index and type is not found. However this is not possible with the current data structure being returned. Needs to be finished for 1.0.
RC1 work completed. Remaining work moved to #4743 |
See issue elastic#4071 PUT options for _mapping: Single type can now be added with `[PUT|POST] {index|_all|*|regex|blank}/[_mapping|_mappings]/type` and `[PUT|POST] {index|_all|*|regex|blank}/type/[_mapping|_mappings]` PUT options for _warmer: PUT with a single warmer can now be done with `[PUT|POST] {index|_all|*|prefix*|blank}/{type|_all|*|prefix*|blank}/[_warmer|_warmers]/warmer_name` PUT options for _alias: Single alias can now be PUT with `[PUT|POST] {index|_all|*|prefix*|blank}/[_alias|_aliases]/alias` DELETE options _mapping: Several mappings can be deleted at once by defining several indices and types with `[DELETE] /{index}/{type}` `[DELETE] /{index}/{type}/_mapping` `[DELETE] /{index}/_mapping/{type}` where `index= * | _all | glob pattern | name1, name2, …` `type= * | _all | glob pattern | name1, name2, …` Alternatively, the keyword `_mapings` can be used. DELETE options for _warmer: Several warmers can be deleted at once by defining several indices and names with `[DELETE] /{index}/_warmer/{type}` where `index= * | _all | glob pattern | name1, name2, …` `type= * | _all | glob pattern | name1, name2, …` Alternatively, the keyword `_warmers` can be used. DELETE options for _alias: Several aliases can be deleted at once by defining several indices and names with `[DELETE] /{index}/_alias/{type}` where `index= * | _all | glob pattern | name1, name2, …` `type= * | _all | glob pattern | name1, name2, …` Alternatively, the keyword `_aliases` can be used.
* Made GET mappings consistent, supporting * /{index}/_mappings/{type} * /{index}/_mapping/{type} * /_mapping/{type} * Added "mappings" in the JSON response to align it with other responses * Made GET warmers consistent, support /{index}/_warmers/{type} and /_warmer, /_warner/{name} as well as wildcards and _all notation * Made GET aliases consistent, support /{index}/_aliases/{name} and /_alias, /_aliases/{name} as well as wildcards and _all notation * Made GET settings consistent, added /{index}/_setting/{name}, /_settings/{name} as well as supportings wildcards in settings name * Returning empty JSON instead of a 404, if a specific warmer/ setting/alias/type is missing * Added a ton of spec tests for all of the above * Added a couple of more integration tests for several features Relates elastic#4071
The get field mapping API now includes a mappings element after the index in its JSON Added more consistent endpoint /{index}/_mapping/{type}/field/{fields} and added endpoint /_mapping/{type}/field/{fields} which are also used in tests Added rest spec tests for wildcards and _all Relates elastic#4071 NOTE: This is not yet complete for 1.0. We need to return an empty JSON document instead of a 404 if the field of an existing index and type is not found. However this is not possible with the current data structure being returned. Needs to be finished for 1.0.
Two questions about this. The first is about a comment @brwe left:
Was this implemented in the end? When I'm posting a mapping containing a type to a URL with a non-matching I see a message acknowledging it but I don't think anything actually happened. Second question is about deprecation. The PUT Mapping API doc mentions this:
Are the singular versions supposed to be removed at some point? |
An index accepts settings, mappings, warmers and aliases. However, some use singular and some use plural, eg:
Mappings:
Settings:
Warmers:
Aliases:
There are a couple of possibilities:
Distinguish between singular and plural when PUT/POSTing
Create/update a mapping, warmer or alias (not settings) with:
This breaks bwc for mapping (
/index/type/_mapping
vs/index/_mapping/type
) - possibly support both variants for all actions?Create/update mappings, warmers, aliases, settings with:
Retrieve via singular or plural:
Alternatively, make singular/plural synonyms, so either can be used in any of the above examples
One final thing, all indices can be specified as
_all
or*
(depending on the API), but eg warmers and aliases only understand wildcards. I think_all
should be an acceptable alias for*
for all of themThe text was updated successfully, but these errors were encountered: