Skip to content
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

ii: remove redudant normalize on search as much as possible #1421

Merged
merged 3 commits into from
Sep 30, 2022

Conversation

komainu8
Copy link
Member

@komainu8 komainu8 commented Sep 28, 2022

Some normalizes such as NormalizerTable aren't idempotent. So we should not normalize the input
multiple times.

The current token_info_open() related codes normalize the input multiple times. This change avoids
multiple normalizations as much as possible. If a tokenizer enables report_source_location, we can
avoid multiple normalizations all time. But if a tokenizer doesn't enable report_source_location, we may
normalize the input multiple times.

See the added tests for problem cases.

@komainu8 komainu8 marked this pull request as ready for review September 28, 2022 22:01
@komainu8
Copy link
Member Author

@kou @HashidaTKS Could you review this PR?

lib/db.c Outdated
@@ -3748,6 +3748,34 @@ grn_table_add_by_key(grn_ctx *ctx, grn_obj *table, grn_obj *key, int *added)
return id;
}

grn_id
grn_table_get_without_normalize(grn_ctx *ctx,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to add this. If we add this, we want to add grn_table_cursor_open_without_nromalize().

I think that this is a ii problem. ii should not re-get token from token id. ii should use source of a token instead of re-getting token. We may be able to use grn_token_get_source_offset() and grn_token_get_source_length() for it. (We can add grn_token_get_source() for convenient.)

komainu8 and others added 3 commits September 30, 2022 15:19
Currently, a search keyword execute normalize twice.
Therefore, the search keyword is normalized involuntarily depending on
settings NormalizerTable.

For example, If we define NormalizerTable as below "BCD" is normalized
like "BCD" -> normalize -> "bcd" -> tokenize -> "bc"/"cd"/"d" ->
normlizer -> "bk"/"cd"/"d".

load --table ColumnNormalizations
[
{"target_column": "c", "normalized": "k"},
{"target_column": "CD", "normalized": "cd"}
]

Therefore, if we use a search keyword "BCD", "ABCD" is not hit.
If we use a search keyword "CD", "ABCD" is hit.
@kou kou changed the title Remove redudant normalize ii: remove redudant normalize on search as much as possible Sep 30, 2022
@komainu8 komainu8 merged commit 864d863 into master Sep 30, 2022
@komainu8 komainu8 deleted the remove-redundant-normalize branch September 30, 2022 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants