+
Skip to content

Conversation

grugna
Copy link
Contributor

@grugna grugna commented Sep 5, 2025

New Features

This is an extension to the filtering features for the guppy graphql endpoint. Guppy historically supported only the “IN” query so a filter if any of the value selected is contained in the data or the “!=” so if any value of the data is in the selected list the data point is excluded. I called for clarity the former ‘CONTAINS_ANY’ and the latter ‘EXCLUDES_ANY’. (

const field = (path !== null && path !== undefined) ? `${path}.${pField}` : pField;
switch (op) {
case '=':
case 'eq':
case 'EQ':
// special case when missingDataAlias is in using
if (config.esConfig.aggregationIncludeMissingData
&& value === config.esConfig.missingDataAlias) {
return {
bool: {
must_not: [
{
exists: {
field,
},
},
],
},
};
}
return {
term: {
[field]: value,
},
};
case 'in':
case 'IN':
// if using missingDataAlias, we need to remove the missingDataAlias from filter values
// and then add a must_not exists bool func to compensate missingDataAlias
if (config.esConfig.aggregationIncludeMissingData
&& value.includes(config.esConfig.missingDataAlias)) {
const newValue = value.filter((element) => element !== config.esConfig.missingDataAlias);
return {
bool: {
should: [
{
bool: {
must_not: [
{
exists: {
field,
},
},
],
},
},
{
terms: {
[field]: newValue,
},
},
],
},
};
}
// if not using missingDataAlias or filter doesn't contain missingDataAlias
return {
terms: {
[field]: value,
},
};
case '!=':
return {
bool: {
must_not: [
{
term: {
[field]: value,
},
},
],
},
};
default:
throw new GraphQLError(`Invalid operation "${op}" in filter argument.`, {
extensions: {
code: 'BAD_USER_INPUT',
},
});
)

I would like to add the ‘CONTAINS_ALL, so all the value selected have to be contained in the data for it to match, and the EXCLUDES_ALL` to exclude a record only if all the selected values are present in the data.
TEMPLATE - Gen3 Community Feature Document (template v1.1).docx

logic high level summary:

  • CONTAINS_ANY:
Filter = [A,B]
Doc [A] → ✅ include
Doc [A,B,C] → ✅ include
Doc [C] → ❌ reject
  • CONTAINS_ALL:
Filter = [A,B]
Doc [A,B] → ✅ include
Doc [A,B,C] → ✅ include
Doc [A] → ❌ reject
  • EXCLUDES_ANY:
Filter = [A,B]
Doc [A] → ❌ reject
Doc [A,B,C] → ❌ reject
Doc [C] → ✅ include
  • EXCLUDES_ALL:
Filter = [A,B]
Doc [A,B] → ❌ reject
Doc [A,B,C] → ❌ reject
Doc [A] → ✅ include
Doc [C] → ✅ include

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.

1 participant

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载