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

Scc 4346/non roman 2 #423

Merged
merged 9 commits into from
Dec 10, 2024
Merged

Scc 4346/non roman 2 #423

merged 9 commits into from
Dec 10, 2024

Conversation

charmingduchess
Copy link
Contributor

@charmingduchess charmingduchess commented Dec 9, 2024

I did some a bunch of refactoring to allow for some fine grained unit testing. I tested this on an integration level by hitting /discovery/resources?q=&filters[creatorLiteral]=순끼 on a local invocation. Not sure if I should add some higher level tests anywhere.

// This builds a filter cause from the value:
const buildClause = (value) => {
// If filtering on a packed field and value isn't a packed value:
if (config.operator === 'match' && value.indexOf('||') < 0 && config.field.match(/_packed$/)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed these references to config.operator === 'match' because we are passing in an array that is already filtered on that condition.

@charmingduchess charmingduchess marked this pull request as ready for review December 9, 2024 21:13
Copy link
Member

@nonword nonword left a comment

Choose a reason for hiding this comment

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

Looking good. Some comments on clarity/ simplification made possible by this work

}

// This builds a filter cause from the value:
buildClause (value, field) {
Copy link
Member

Choose a reason for hiding this comment

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

Seems too general a name for the specific thing it's doing? Could it be:

buildFilterClause (value, fieldConfig)

issuance: { operator: 'match', field: 'issuance_packed', repeatable: true },
createdYear: { operator: 'match', field: 'createdYear', repeatable: true },
recordType: { operator: 'match', field: ['recordTypeId'], repeatable: true },
owner: { operator: 'match', field: ['items.owner_packed'], repeatable: true, path: 'items' },
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't need to happen as part of this, but because this enables matching on multiple fields, you could change these _packed configs to match explicitly on each entity subfield. For example, above could use field ['items.owner.id', 'items.owner.label'], since that's how the clause ultimately manifests, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yess I like that. I knew there was something there because their structure was so similar.

lib/elasticsearch/elastic-query-builder.js Outdated Show resolved Hide resolved
lib/elasticsearch/elastic-query-builder.js Outdated Show resolved Hide resolved
lib/elasticsearch/elastic-query-builder.js Outdated Show resolved Hide resolved
lib/elasticsearch/config.js Outdated Show resolved Hide resolved
Copy link
Member

@nonword nonword left a comment

Choose a reason for hiding this comment

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

Great work

buildMultiFieldClause: ElasticQueryBuilder.prototype.buildMultiFieldClause,
buildMatchOperatorFilterQueries: ElasticQueryBuilder.prototype.buildMatchOperatorFilterQueries,
buildFilterClause: ElasticQueryBuilder.prototype.buildFilterClause,
buildPackedFieldClause: ElasticQueryBuilder.prototype.buildPackedFieldClause
Copy link
Member

Choose a reason for hiding this comment

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

Can be removd

@charmingduchess charmingduchess merged commit 2a4f75b into main Dec 10, 2024
4 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.

2 participants