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

Support "CONTAIN" filter condition #114

Open
jjoyce0510 opened this issue Jul 12, 2021 · 0 comments
Open

Support "CONTAIN" filter condition #114

jjoyce0510 opened this issue Jul 12, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@jjoyce0510
Copy link

Describe the bug A clear and concise description of what the bug is.

Currently, the "CONTAIN" filter condition is not supported in Search, because the getQueryBuilderFromCriterion in SearchUtils class explicitly does not support it.

    final Condition condition = criterion.getCondition();
    if (condition == Condition.EQUAL) {
      if (criterion.getValue().startsWith("urn:li:")) {
        return QueryBuilders.termsQuery(criterion.getField(), criterion.getValue().trim());
      }
      return QueryBuilders.termsQuery(criterion.getField(), criterion.getValue().trim().split("\\s*,\\s*"));
    } else if (condition == Condition.GREATER_THAN) {
      return QueryBuilders.rangeQuery(criterion.getField()).gt(criterion.getValue().trim());
    } else if (condition == Condition.GREATER_THAN_OR_EQUAL_TO) {
      return QueryBuilders.rangeQuery(criterion.getField()).gte(criterion.getValue().trim());
    } else if (condition == Condition.LESS_THAN) {
      return QueryBuilders.rangeQuery(criterion.getField()).lt(criterion.getValue().trim());
    } else if (condition == Condition.LESS_THAN_OR_EQUAL_TO) {
      return QueryBuilders.rangeQuery(criterion.getField()).lte(criterion.getValue().trim());
    }

    throw new UnsupportedOperationException("Unsupported condition: " + condition);
  }```

(even though it exists in the Filter Condition enum.


#### To Reproduce

Steps to reproduce the behavior:

1. Deploy DataHub
2. Issue a Search Query with a specific "filter" criteria that has the condition "CONTAIN". You'll see a server error returned. 

![image](https://user-images.githubusercontent.com/17549204/125294210-efdd4080-e2d8-11eb-8a0d-143f87c93453.png)


#### Expected behavior

Contains operator should work for substring of string fields. 

As reported by Lal Rishav at Saxo Bank!

#### Screenshots If applicable, add screenshots to help explain your problem.

#### Desktop (please complete the following information):

- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

#### Additional context

Add any other context about the problem here.
@jjoyce0510 jjoyce0510 added the bug Something isn't working label Jul 12, 2021
yangyangv2 added a commit that referenced this issue Jul 14, 2021
This fix to address the issue #114
yangyangv2 added a commit that referenced this issue Jul 22, 2021
This fix to address the issue #114
yangyangv2 added a commit that referenced this issue Jul 22, 2021
This fix to address the issue #114
yangyangv2 added a commit that referenced this issue Jul 27, 2021
This fix to address the issue #114
keremsahin1 pushed a commit that referenced this issue Jul 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant