-
Notifications
You must be signed in to change notification settings - Fork 461
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
feat(sdk-client): Lucene Query Builder Architecture #28539
Merged
fmontes
merged 25 commits into
master
from
28537-sdk-simple-lucene-query-builder-for-content-api
May 20, 2024
Merged
feat(sdk-client): Lucene Query Builder Architecture #28539
fmontes
merged 25 commits into
master
from
28537-sdk-simple-lucene-query-builder-for-content-api
May 20, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
zJaaal
requested review from
fmontes,
oidacra,
hmoreras,
rjvelazco and
KevinDavilaDotCMS
May 13, 2024 17:00
https://github.com/dotCMS/core into 28537-sdk-simple-lucene-query-builder-for-content-api
https://github.com/dotCMS/core into 28537-sdk-simple-lucene-query-builder-for-content-api
https://github.com/dotCMS/core into 28537-sdk-simple-lucene-query-builder-for-content-api
fmontes
requested changes
May 14, 2024
core-web/libs/sdk/client/src/lib/query-builder/sdk-query-builder.spec.ts
Outdated
Show resolved
Hide resolved
oidacra
reviewed
May 14, 2024
core-web/libs/sdk/client/src/lib/query-builder/sdk-query-builder.spec.ts
Show resolved
Hide resolved
fmontes
approved these changes
May 20, 2024
oidacra
approved these changes
May 20, 2024
Quality Gate passedIssues Measures |
rjvelazco
approved these changes
May 20, 2024
KevinDavilaDotCMS
approved these changes
May 20, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed changes
QueryBuilder
to handle the simple cases of building a Lucene QueryLucene Syntax
Note
I used this docs as reference for this Query Builder
Field
Lucene supports fielded data. When performing a search you can either specify a field, or use the default field. The field names and default field is implementation specific.
You can search any field by typing the field name followed by a colon ":" and then the term you are looking for.
Example:
+myField:
Term
A query is broken up into terms and operators. There are two types of terms: Single Terms and Phrases.
A Single Term is a single word such as "test" or "hello".
A Phrase is a group of words surrounded by double quotes such as "hello dolly".
Operand
Boolean operators allow terms to be combined through logic operators. Lucene supports AND, "+", OR, NOT and "-" as Boolean operators(Note: Boolean operators must be ALL CAPS).
By the time, we only support
OR
,AND
&NOT
Architecture Diagram
I used a combination of composite and builder pattern to create a cycle that allows the developer to always write a lucene query with a correct syntax and avoid early building of queries.
Look how we can only end the cycle by getting to a
term
and calling thebuild
method, this is to prevent the building of invalid Queries.We can say that a Lucene Query should always end in a Term to be valid and complete.
Update: Term naming was changed to Equals in the code.