-
Notifications
You must be signed in to change notification settings - Fork 45
Adds support for dynamically updatable search analyzers #290
Adds support for dynamically updatable search analyzers #290
Conversation
commit c8c8233 Author: Himanshu Setia <[email protected]> Date: Tue Sep 8 19:21:58 2020 -0700 removing comments, linting changes commit 52526e8 Author: Himanshu Setia <[email protected]> Date: Tue Sep 8 19:09:30 2020 -0700 Making refresh_synonym_analyzer uri odfe compatible commit d4cc71e Author: Himanshu Setia <[email protected]> Date: Tue Sep 8 18:33:39 2020 -0700 Adding copyright disclaimer to new files commit 9af7fdf Author: Himanshu Setia <[email protected]> Date: Tue Sep 8 17:26:53 2020 -0700 Misc - removing comments, adding newline, etc. commit 1c85f18 Author: Himanshu Setia <[email protected]> Date: Tue Sep 8 16:39:26 2020 -0700 Adding _refresh_synonym_analyzer API to support dynamic update for search analyzers
Codecov Report
@@ Coverage Diff @@
## master #290 +/- ##
============================================
- Coverage 75.32% 74.83% -0.50%
- Complexity 703 718 +15
============================================
Files 89 95 +6
Lines 3919 4009 +90
Branches 625 633 +8
============================================
+ Hits 2952 3000 +48
- Misses 641 683 +42
Partials 326 326
Continue to review full report at Codecov.
|
In the process of adding more UTs to close the codecov/patch gap |
.../opendistroforelasticsearch/indexmanagement/refreshanalyzer/RefreshSearchAnalyzerResponse.kt
Outdated
Show resolved
Hide resolved
.../opendistroforelasticsearch/indexmanagement/refreshanalyzer/RefreshSearchAnalyzerResponse.kt
Outdated
Show resolved
Hide resolved
...distroforelasticsearch/indexmanagement/refreshanalyzer/RefreshSearchAnalyzerShardResponse.kt
Outdated
Show resolved
Hide resolved
...stroforelasticsearch/indexmanagement/refreshanalyzer/TransportRefreshSearchAnalyzerAction.kt
Outdated
Show resolved
Hide resolved
.../opendistroforelasticsearch/indexmanagement/refreshanalyzer/RefreshSearchAnalyzerActionIT.kt
Outdated
Show resolved
Hide resolved
.../opendistroforelasticsearch/indexmanagement/refreshanalyzer/RefreshSearchAnalyzerActionIT.kt
Outdated
Show resolved
Hide resolved
@Throws(IOException::class) | ||
constructor(inp: StreamInput) : super(inp) { | ||
val resultSize: Int = inp.readVInt() | ||
for (i in 0..resultSize) { |
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.
Is this a common pattern you saw elsewhere for reading off streaminput?
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.
Also, does this constructor only take the streaminput in the format outputted by writeTo
? if so, you can change writeTo
to do something like:
out.writeList(shardResponses)
and then here you can read the list and pass a class reference to the element of the list (assuming it's Writeable
)
inp.readList(::RefreshSearchAnalyzerShardResponse)
You can find a similar example of this in the Monitor data class for Alerting
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.
I found this pattern in BroadcastResponse.java, although the one that Mohammad suggested looks to be a better way. I have modified it in my latest commit. Thanks for the suggestion Mo!
|
||
val failureSize: Int = inp.readVInt() | ||
for (i in 0..failureSize) { | ||
shardFailures.add(FailedShardDetails(inp.readString(), inp.readInt(), inp.readString())) |
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.
nit: Make FailedShardDetails writeable and just pass in the streaminput/output
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.
Good point. I wanted to do some refactoring on this but couldn't get to it earlier. It's done now, the new version does not use this class now.
private val analysisRegistry: AnalysisRegistry | ||
|
||
@Throws(IOException::class) | ||
override fun readShardResult(`in`: StreamInput): RefreshSearchAnalyzerShardResponse? { |
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.
Remove nullable return type as it seems to never be null
} | ||
|
||
override fun newResponse( | ||
request: RefreshSearchAnalyzerRequest?, |
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.
Just checking: can this be null or was this just from autocomplete from IDE
failedShards: Int, | ||
results: List<RefreshSearchAnalyzerShardResponse>, | ||
shardFailures: List<DefaultShardOperationFailedException>, | ||
clusterState: ClusterState? |
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.
Just checking: can this be null or was this just from autocomplete from IDE
} | ||
|
||
@Throws(IOException::class) | ||
override fun readRequestFrom(`in`: StreamInput): RefreshSearchAnalyzerRequest? { |
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.
Remove nullable
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.
sure
...pendistroforelasticsearch/indexmanagement/refreshanalyzer/RestRefreshSearchAnalyzerAction.kt
Outdated
Show resolved
Hide resolved
val expectedErrorMessage = mapOf( | ||
"error" to mapOf( | ||
"root_cause" to listOf<Map<String, Any>>( | ||
mapOf("type" to "parse_exception", "reason" to "request body is required") | ||
), | ||
"type" to "parse_exception", | ||
"reason" to "request body is required" | ||
), | ||
"status" to 400 | ||
) |
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.
This seems to be not what you are trying to test? If testing for missing indices I'd expect to see an expected message for throw IllegalArgumentException("Missing indices")
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.
the uri change caused the exception behavior to change. I will revert back the uri and change this back
.../opendistroforelasticsearch/indexmanagement/refreshanalyzer/RefreshSearchAnalyzerActionIT.kt
Outdated
Show resolved
Hide resolved
.../opendistroforelasticsearch/indexmanagement/refreshanalyzer/RefreshSearchAnalyzerActionIT.kt
Outdated
Show resolved
Hide resolved
Squashed commit of the following: commit d87842e4ccb592a39d6b6897a2b9cde9ddc2839f Author: Himanshu Setia <[email protected]> Date: Thu Sep 10 23:36:24 2020 -0700 Reverting RefreshSearchAnalyzerResponse stream input output parsing test for fixing later commit 33ef3223acde38a64575255f7ec702f807d0502e Author: Himanshu Setia <[email protected]> Date: Thu Sep 10 23:34:49 2020 -0700 Fixing missing indices test commit 8516d2142362c61630682bf7353e019bf9f6a9eb Author: Himanshu Setia <[email protected]> Date: Thu Sep 10 21:59:55 2020 -0700 CR comments and added more UTs commit d306421ca462f2614756a73231baeeb56b388365 Author: Himanshu Setia <[email protected]> Date: Thu Sep 10 20:15:59 2020 -0700 shardFailure refactoring commit da80de7a68fef05e524e624ea1a8da6afdbf11d4 Author: Himanshu Setia <[email protected]> Date: Thu Sep 10 18:14:45 2020 -0700 Working changes after refactoring shardFailure commit be9bf2daaa31fb6444f799a8f3ed3d0383551471 Author: Himanshu Setia <[email protected]> Date: Thu Sep 10 17:45:31 2020 -0700 Corrected response parsing for indices with some failed shards commit 256f06ed23ac4ab2d78724601a1dd7e9d1423331 Author: Himanshu Setia <[email protected]> Date: Thu Sep 10 17:12:00 2020 -0700 Working
@@ -20,7 +20,7 @@ import org.elasticsearch.common.io.stream.Writeable | |||
|
|||
class RefreshSearchAnalyzerAction : ActionType<RefreshSearchAnalyzerResponse>(NAME, reader) { | |||
companion object { | |||
const val NAME = "indices:admin/refresh_search_analyzer" | |||
const val NAME = "indices:admin/_refresh_search_analyzers" |
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.
Is it common to prefix _ on the action names?
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.
You're right, it's not. Will change back to indices:admin/refresh_search_analyzers
Issue #, if available:
Description of changes:
This change is to add support for hot update of search analyzers in Elasticsearch. It exposes a new REST Api
POST /_opendistro/_refresh_search_analyzers/{index}
, which when invoked, refreshes those analyzers in memory which were created with is_updateable flag as true. This can be used to refresh synonym list used for search time analysis, without closing and reopening the index.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.