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

(dsl): Support Fuzzy query #347

Merged
merged 5 commits into from
Oct 31, 2023
Merged

Conversation

vanjaftn
Copy link
Contributor

@vanjaftn vanjaftn commented Oct 30, 2023

Part of #91

* the ability to find results that are similar to, but not exactly the same as, the search term or query
*
* @param value
* the [[String]] value to represent the 'fuzziness' field
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* the [[String]] value to represent the 'fuzziness' field
* the text value to represent the 'fuzziness' field

* @param value
* the [[String]] value to represent the 'fuzziness' field
* @return
* a new instance of the [[zio.elasticsearch.query.ElasticQuery]] with the `fuzziness` value set.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* a new instance of the [[zio.elasticsearch.query.ElasticQuery]] with the `fuzziness` value set.
* an instance of the [[zio.elasticsearch.query.ElasticQuery]] enriched with the `fuzziness` parameter.


/**
* Sets the `fuzziness` parameter for this [[zio.elasticsearch.query.ElasticQuery]]. The `fuzziness` value refers to
* the ability to find results that are similar to, but not exactly the same as, the search term or query
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* the ability to find results that are similar to, but not exactly the same as, the search term or query
* the ability to find results that are similar to, but not exactly the same as, the search term or query.


/**
* Sets the `maxExpansions` parameter for this [[zio.elasticsearch.query.ElasticQuery]]. The `maxExpansions` value
* defines the maximum number of terms the fuzzy query will match before halting the search
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* defines the maximum number of terms the fuzzy query will match before halting the search
* defines the maximum number of terms the fuzzy query will match before halting the search.

* defines the maximum number of terms the fuzzy query will match before halting the search
*
* @param value
* the whole number value for `maxExpansions` parameter
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* the whole number value for `maxExpansions` parameter
* the positive whole number value for `maxExpansions` parameter

* refers to the number of beginning characters left unchanged when creating expansions
*
* @param value
* the whole number value for `prefixLength` parameter
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* the whole number value for `prefixLength` parameter
* the positive whole number value for `prefixLength` parameter

* @param value
* the whole number value for `prefixLength` parameter
* @return
* a new instance of the [[zio.elasticsearch.query.ElasticQuery]] with the `prefixLength` value set.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above.

@@ -1010,6 +1010,29 @@ object HttpExecutorSpec extends IntegrationSpec {
Executor.execute(ElasticRequest.createIndex(firstSearchIndex)),
Executor.execute(ElasticRequest.deleteIndex(firstSearchIndex)).orDie
),
test("search for a document which changes a character using a fuzzy query") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you rephrase this test text?

@@ -582,6 +582,81 @@ object ElasticQuerySpec extends ZIOSpecDefault {
)
)
},
test("fuzzy") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add one test for all parameters together.

@@ -2189,6 +2264,79 @@ object ElasticQuerySpec extends ZIOSpecDefault {
assert(queryTs.toJson(fieldPath = None))(equalTo(expectedTs.toJson)) &&
assert(queryTsWithBoost.toJson(fieldPath = None))(equalTo(expectedTsWithBoost.toJson))
},
test("fuzzy") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here also.

title: "Fuzzy Query"
---

The `Fuzzy` query returns documents that contain terms similar to the search term, as measured by a Levenshtein edit distance.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add a link to this Levenshtein edit distance.
https://en.wikipedia.org/wiki/Levenshtein_distance

@@ -588,7 +588,9 @@ object ElasticQuerySpec extends ZIOSpecDefault {
val queryWithCaseFuzzinessAuto = fuzzy(TestDocument.stringField, "test").fuzziness("AUTO")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Omit Case.

@@ -588,7 +588,9 @@ object ElasticQuerySpec extends ZIOSpecDefault {
val queryWithCaseFuzzinessAuto = fuzzy(TestDocument.stringField, "test").fuzziness("AUTO")
val queryWithCaseMaxExpansions = fuzzy(TestDocument.stringField, "test").maxExpansions(50)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here also.

@dbulaja98 dbulaja98 merged commit b80dc97 into lambdaworks:main Oct 31, 2023
13 checks passed
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