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

[DOC] Tokenizer - Edge-n-gram #8378

Merged

Conversation

leanneeliatra
Copy link
Contributor

Description

Addition of the Tokenizer Edge-n-gram documentation, to the Analyzers section.

Issues Resolved

Part of #1483 addressed in this PR.

Version

All

Frontend features

n/a

Checklist

  • By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and subject to the Developers Certificate of Origin.
    For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Copy link

Thank you for submitting your PR. The PR states are In progress (or Draft) -> Tech review -> Doc review -> Editorial review -> Merged.

Before you submit your PR for doc review, make sure the content is technically accurate. If you need help finding a tech reviewer, tag a maintainer.

When you're ready for doc review, tag the assignee of this PR. The doc reviewer may push edits to the PR directly or leave comments and editorial suggestions for you to address (let us know in a comment if you have a preference). The doc reviewer will arrange for an editorial review.

@kolchfa-aws kolchfa-aws assigned vagimeli and unassigned kolchfa-aws Sep 25, 2024
@vagimeli vagimeli added the 2 - In progress Issue/PR: The issue or PR is in progress. label Sep 25, 2024
@leanneeliatra leanneeliatra marked this pull request as ready for review September 27, 2024 16:21
@vagimeli vagimeli added 3 - Tech review PR: Tech review in progress Needs SME Waiting on input from subject matter expert analyzers and removed 2 - In progress Issue/PR: The issue or PR is in progress. labels Sep 30, 2024
@vagimeli
Copy link
Contributor

@udabhas Will you review this PR for technical accuracy, or have a peer review it? Thank you.

Copy link

@udabhas udabhas left a comment

Choose a reason for hiding this comment

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

Looks good to me.

Signed-off-by: Fanit Kolchina <[email protected]>
@kolchfa-aws kolchfa-aws assigned kolchfa-aws and unassigned vagimeli Jan 2, 2025
@kolchfa-aws kolchfa-aws added the backport 2.18 PR: Backport label for 2.18 label Jan 2, 2025
Copy link
Collaborator

@natebower natebower left a comment

Choose a reason for hiding this comment

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

@kolchfa-aws Please see my comments and changes and tag me for approval when complete. Thanks!

_analyzers/tokenizers/edge-n-gram.md Outdated Show resolved Hide resolved
# Edge n-gram tokenizer

The `edge_ngram` tokenizer generates partial word tokens, or n-grams, starting from the beginning of each word. It splits the text based on specified characters and produces tokens with lengths defined by a minimum and maximum length. This tokenizer is particularly useful for implementing search-as-you-type functionality.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Line 10: If my rewrite to the second sentence isn't quite right, then let's name what we're referring to: "produces tokens of lengths defined by min_gram and max_gram."

_analyzers/tokenizers/edge-n-gram.md Outdated Show resolved Hide resolved
The `edge_ngram` tokenizer generates partial word tokens, or n-grams, starting from the beginning of each word. It splits the text based on specified characters and produces tokens with lengths defined by a minimum and maximum length. This tokenizer is particularly useful for implementing search-as-you-type functionality.

Edge n-grams are ideal for autocomplete searches where the order of the words may vary, such as with product names or addresses. For more information, see [Autocomplete]({{site.url}}{{site.baseurl}}/search-plugins/searching-data/autocomplete/). However, for text with a fixed order, like movie or song titles, the completion suggester may be more efficient.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Line 12: "efficient" => "accurate"?

_analyzers/tokenizers/edge-n-gram.md Outdated Show resolved Hide resolved

## Configuring search as you type

To implement search-as-you-type functionality, use the `edge_ngram` tokenizer during indexing and a simpler analyzer at search time. The following configuration demonstrates this approach:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment re: "a simpler analyzer". What/which ones would constitute "a simpler analyzer"?

```
{% include copy-curl.html %}

Index a document containing a `product` field and refresh the index:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This line reads as though we're providing instructions, but line 128 implies merely a demonstration.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Reworded the previous line as instructions

_analyzers/tokenizers/edge-n-gram.md Outdated Show resolved Hide resolved
{% include copy-curl.html %}

This configuration ensures that the `edge_ngram` tokenizer breaks terms like Laptop into tokens such as `La`, `Lap`, and `Lapt`, allowing partial matches during search. At search time, the standard tokenizer simplifies queries while ensuring matches are case-insensitive because of the lowercase filter.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is "the standard tokenizer" what we mean by "a simpler analyzer" on lines 124 and 128?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No, the standard tokenizer.

_analyzers/tokenizers/edge-n-gram.md Outdated Show resolved Hide resolved
Co-authored-by: Nathan Bower <[email protected]>
Signed-off-by: kolchfa-aws <[email protected]>
Copy link
Collaborator

@natebower natebower left a comment

Choose a reason for hiding this comment

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

@kolchfa-aws LGTM!

@kolchfa-aws kolchfa-aws merged commit ca0cc23 into opensearch-project:main Jan 3, 2025
5 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jan 3, 2025
* adding doucmentation for n-gram-tokenizer

Signed-off-by: [email protected] <[email protected]>

* tokenizers edge-n-gram

Signed-off-by: [email protected] <[email protected]>

* format: formatting updates to page

Signed-off-by: [email protected] <[email protected]>

* format: formatting updates to page

Signed-off-by: [email protected] <[email protected]>

* format: formatting updates to page

Signed-off-by: [email protected] <[email protected]>

* Doc review

Signed-off-by: Fanit Kolchina <[email protected]>

* Apply suggestions from code review

Co-authored-by: Nathan Bower <[email protected]>
Signed-off-by: kolchfa-aws <[email protected]>

* Update _analyzers/tokenizers/edge-n-gram.md

Co-authored-by: Nathan Bower <[email protected]>
Signed-off-by: kolchfa-aws <[email protected]>

* Update _analyzers/tokenizers/edge-n-gram.md

Co-authored-by: Nathan Bower <[email protected]>
Signed-off-by: kolchfa-aws <[email protected]>

* Update _analyzers/tokenizers/edge-n-gram.md

Co-authored-by: Nathan Bower <[email protected]>
Signed-off-by: kolchfa-aws <[email protected]>

---------

Signed-off-by: [email protected] <[email protected]>
Signed-off-by: Fanit Kolchina <[email protected]>
Signed-off-by: kolchfa-aws <[email protected]>
Co-authored-by: Fanit Kolchina <[email protected]>
Co-authored-by: kolchfa-aws <[email protected]>
Co-authored-by: Nathan Bower <[email protected]>
(cherry picked from commit ca0cc23)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
github-actions bot pushed a commit that referenced this pull request Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 - Tech review PR: Tech review in progress analyzers backport 2.18 PR: Backport label for 2.18 Content gap Needs SME Waiting on input from subject matter expert
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants