-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
add is-write-index flag to aliases #30942
Changes from 8 commits
5838717
7baf86b
19315ff
440fed4
135d7c1
5bb7217
847bbe6
32ca015
07188f3
01fab60
c7a3a96
8df9bc8
4e898c1
1aac672
5ea9725
1c9e28f
4755a10
ae2b0c9
545c801
a614010
ee4142d
8c33d23
0025a51
373c1e5
ba1162c
a1391b2
91deba4
1629aef
f8dba0c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -244,6 +244,94 @@ GET /alias2/_search?q=user:kimchy&routing=2,3 | |
// CONSOLE | ||
// TEST[continued] | ||
|
||
[float] | ||
[[aliases-write-index]] | ||
==== Write Index | ||
|
||
It is possible to associate the index pointed to by an alias as the write index. | ||
When specified, all index and update requests against an alias that point to multiple | ||
indices will attempt to resolve to the one index that is the write index. If no such index is | ||
found, then an exception will be thrown. | ||
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. maybe add that only one index per alias can have the flag? |
||
|
||
It is possible to specify an index associated with an alias as a write index using both the aliases API | ||
and index creation API. | ||
|
||
[source,js] | ||
-------------------------------------------------- | ||
POST /_aliases | ||
{ | ||
"actions" : [ | ||
{ | ||
"add" : { | ||
"index" : "test", | ||
"alias" : "alias1", | ||
"is_write_index" : true | ||
} | ||
} | ||
] | ||
} | ||
-------------------------------------------------- | ||
// CONSOLE | ||
// TEST[s/^/PUT test\n/] | ||
|
||
In this example, we associate the alias `alias1` to both `test` and `test2`, where | ||
`test` will be the index chosen for writing to. | ||
|
||
[source,js] | ||
-------------------------------------------------- | ||
PUT /alias1/_doc/1 | ||
{ | ||
"foo": "bar" | ||
} | ||
-------------------------------------------------- | ||
// CONSOLE | ||
// TEST[continued] | ||
|
||
The new document that was indexed to `/alias1/_doc/1` will be indexed as if it were | ||
`/test/_doc/1`. | ||
|
||
[source,js] | ||
-------------------------------------------------- | ||
GET /test/_doc/1 | ||
-------------------------------------------------- | ||
// CONSOLE | ||
// TEST[continued] | ||
|
||
To swap which index is the write index for an alias, the Aliases API can be leveraged to | ||
do an atomic swap. The swap is not dependent on the ordering of the actions. | ||
|
||
[source,js] | ||
-------------------------------------------------- | ||
POST /_aliases | ||
{ | ||
"actions" : [ | ||
{ | ||
"add" : { | ||
"index" : "test", | ||
"alias" : "alias1", | ||
"is_write_index" : true | ||
} | ||
}, { | ||
"add" : { | ||
"index" : "test2", | ||
"alias" : "alias1", | ||
"is_write_index" : false | ||
} | ||
} | ||
] | ||
} | ||
-------------------------------------------------- | ||
// CONSOLE | ||
// TEST[s/^/PUT test\nPUT test2\n/] | ||
|
||
It is important to note that the order of these actions is important. The original write index | ||
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. This is tricky - with our new model the order is not important but it is that you remove an explicit flag. I wonder if we should add a section over the "default" behavior and illustrate some examples. 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. oh, woops. I thought I went through this. will update since it is left-over and currently wrong |
||
must be unset, so that `test2` can be set as the write index. | ||
|
||
|
||
[IMPORTANT] | ||
===================================== | ||
`is_write_index` will default to `true` for an index that only has one alias which did not explicitly specify a value. | ||
===================================== | ||
|
||
[float] | ||
[[alias-adding]] | ||
|
@@ -419,7 +507,8 @@ Response: | |
"term" : { | ||
"year" : 2016 | ||
} | ||
} | ||
}, | ||
"is_write_index": false | ||
} | ||
} | ||
} | ||
|
@@ -448,7 +537,8 @@ Response: | |
"term" : { | ||
"year" : 2016 | ||
} | ||
} | ||
}, | ||
"is_write_index": false | ||
} | ||
} | ||
} | ||
|
@@ -477,7 +567,8 @@ Response: | |
"term" : { | ||
"year" : 2016 | ||
} | ||
} | ||
}, | ||
"is_write_index": false | ||
} | ||
} | ||
} | ||
|
This comment was marked as resolved.
Sorry, something went wrong.