-
Notifications
You must be signed in to change notification settings - Fork 17
ALIS-1265: create tag case insensitive #164
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
ALIS-1265: create tag case insensitive #164
Conversation
To save tags case-insensitive
| } | ||
| } | ||
| } | ||
| create_index_list.append({"name": "tags", "setting": tag_settings}) |
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.
[質問] ESのmappingなどのリリースって現状どう行なっているのでしょうか?
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.
あと、このスクリプトをローカルで動かそうとするとendpointの正規表現のところでコケてしまったんですが、既知の問題だったりしますか?
もし既知の問題であれば調べるのにコストかけるよりも聞いてしまいたいってのが背景なので、道であれば調査します。
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.
ES に関わるリリースは、ブルー・グリーンデプロイを行っています。
また、 endpoint 箇所でコケる件ですが、もしかしたら実行方法に問題あるかもしれません。
下記のように形で、ローカルIPを引数として渡しているか一度ご確認いただければと思います。
python elasticsearch-setup.py $(curl https://checkip.amazonaws.com/)
| 'properties': { | ||
| 'name': { | ||
| 'type': 'keyword', | ||
| 'normalizer': 'lowercase_normalizer' |
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.
このように keyword で指定しておいて、normalizer で小文字フィルターをかけてあげると
Term level queries(言語解析されずに検索) で、かつ 大文字でも小文字でも検索対象になる ようにできる
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.
上記精査ありがとうございます!
src/common/tag_util.py
Outdated
| ) | ||
|
|
||
| # デフォルトのrefresh_intervalだと、1sほど作成されたタグが検索対象にならないのでセグメントマージを強制的に行う | ||
| elasticsearch.indices.refresh(index='tags') |
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.
ここは相当悩ましかったんですがPRの説明にも書いたように、明示的にRefreshしてます(これをすることによって、インメモリバッファからディスク書き込みが行われ、検索可能になる)
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.
セグメントマージはあまりに高頻度だと逆にパフォーマンスも劣化するんですが、この処理自体それほど頻度が多いものではないので大丈夫だろうと判断しています。
src/common/tag_util.py
Outdated
| ) | ||
|
|
||
| # デフォルトのrefresh_intervalだと、1sほど作成されたタグが検索対象にならないのでセグメントマージを強制的に行う | ||
| elasticsearch.indices.refresh(index='tags') |
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.
セグメントマージはあまりに高頻度だと逆にパフォーマンスも劣化するんですが、この処理自体それほど頻度が多いものではないので大丈夫だろうと判断しています。
| """ | ||
| 与えられたタグ名をElasticSearchに問い合わせ(大文字小文字区別せず) | ||
| すでに存在する場合はElasticSearchに存在する文字列に完全一致する形に変換し、タグ名の配列を返却する | ||
| """ |
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.
やってることは単純だが意図がわかりづらいのでコメント追加
| else: | ||
| results.append(tag_name) | ||
|
|
||
| return results |
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.
リスト内包表記とかでもかけるのだが、上にも書いたようにすこし意図がわかりにくいのであえて冗長に書いている
| 'count': num | ||
| } | ||
| } | ||
| } |
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.
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.
Note, this operation still means full reindex of the document, it just removes some network roundtrips and reduces chances of version conflicts between the get and the index. The _source field needs to be enabled for this feature to work.
にあるように、一回取得して〜カウントして〜更新して〜、と比べると
- ラウンドトリップが減る
- その分整合性がおかしくなる可能性が減る
という話であって整合性が保たれるわけではなく、ダーティリード的なものは起こりうる、というところは注意。
と言ってもDynamoDBのatomic counterも整合性は保証されないので、整合性レベルが低くなるわけではない
https://docs.aws.amazon.com/ja_jp/amazondynamodb/latest/developerguide/WorkingWithItems.html#WorkingWithItems.AtomicCounters
概要
環境変数(SSMパラメータ)
なし
関連URL
影響範囲(ユーザ)
リリースに気をつけないとユーザ影響あり。後述する
影響範囲(システム)
技術的変更点概要
DBやDBへのクエリに対する変更
注意点・その他