OpenMetadata icon indicating copy to clipboard operation
OpenMetadata copied to clipboard

[Bug] Advanced Search: Number custom property "between" filter returns all entities that have the property set, ignoring the range bounds; sometimes search API is not called

Open Rohit0301 opened this issue 7 months ago • 16 comments

When using Advanced Search with a number type custom property and the between operator, two issues are observed:

The filter ignores the specified range and returns all entities that have the custom property set — regardless of whether the value falls within the range. For example, filtering between 1 and 5 returns an entity with value 100. Sometimes when the between operator is selected and values are entered, the search API is not triggered at all — the results remain stale from the previous query.

https://github.com/user-attachments/assets/225bae10-a742-4985-988c-1fd61e191947

Rohit0301 avatar Apr 17 '26 12:04 Rohit0301

Hi @chirag-madlani @Rohit0301 I would like to work on this. Could you plz assign this issue to me?

hassaansaleem28 avatar Apr 17 '26 12:04 hassaansaleem28

Hi, @chirag-madlani I’m interested in working on this issue. I’ll try to reproduce it locally and investigate both the incorrect between range behavior and the missing search API trigger.

Vinayreddy765 avatar Apr 17 '26 13:04 Vinayreddy765

Hi @chirag-madlani @ulixius9 Please assign this issue to me, I would like to fix this.

miantalha45 avatar Apr 17 '26 13:04 miantalha45

https://github.com/user-attachments/assets/44e02d3b-23f8-4498-8af3-2307b12de297

I have reproduced it on my local, and now i am ready to fix it. Please assign this to me.

miantalha45 avatar Apr 17 '26 13:04 miantalha45

Hi @chirag-madlani @Rohit0301 — I've analyzed both issues:

  1. The "between" filter is likely building the range query incorrectly — missing gte/lte bounds in the Elasticsearch query construction.

  2. The missing API trigger is likely a useEffect dependency issue on the second input field not firing the search call.

I'm digging into the search filter logic now to pinpoint the exact files. Can you assign this to me?

Shivang731 avatar Apr 17 '26 13:04 Shivang731

Hi, I’d like to work on this issue.

From the description, it seems there are two problems:

  1. The "between" filter is not correctly applying range conditions, so it returns all entities instead of filtering within bounds.
  2. The search API not triggering might be related to how the input state is handled when updating the second value.

I’ll try to reproduce this locally and investigate both the query construction and UI behavior.

Could you please assign it to me?

amruta7974 avatar Apr 17 '26 14:04 amruta7974

Hi, I can take ownership of this issue and fix the advanced search between filter for number custom properties. I will trace the query-builder logic and the React UI state that fails to dispatch the API call when the second boundary is inputted. Please assign me for the WeMakeDevs Hackathon!

aniruddhaadak80 avatar Apr 17 '26 14:04 aniruddhaadak80

Hi @Rohit0301 I would like to work on this one for the hackathon, can you please assign it to me?

0xharp avatar Apr 18 '26 09:04 0xharp

Hi @Rohit0301, I would like to work on this one for the hackathon. Can you please assign it to me?

According to my analysis:

1. The Database Ignores "Between" Filters

Problem: The code that translates your filters to the database doesn't know what "between" or "not between" means. Since it doesn't understand the command, it just ignores the filter and returns all the results.

Solution: Add a specific rule teaching the code how to handle "between" (looking for a range from a start value to an end value) and "not between" (doing the exact opposite).

2. The Search Doesn't Trigger on the Second Number

Problem: In the automated test, typing the second number into the "between" boxes doesn't actually tell the app to update. The system only notices when the first box changes.

Solution: Update the test to make sure the app registers both inputs. You can do this by having the test press "Enter" or "Tab" after filling out each individual box before it tries to run the search.

ayushgupta-h avatar Apr 18 '26 19:04 ayushgupta-h

@chirag-madlani please assign this issue to me

ayushk687 avatar Apr 18 '26 21:04 ayushk687

hey @Rohit0301 @chirag-madlani i would love to work on it could you please assign it to me ? thanks

RajdeepKushwaha5 avatar Apr 19 '26 09:04 RajdeepKushwaha5

Hi @Rohit0301 @chirag-madlani 👋

Update: PR submitted → (https://github.com/open-metadata/OpenMetadata/pull/27525)

What I found after deep diagnosis:

The root cause is purely in QueryBuilderElasticsearchFormatUtils.js — the buildEsRule function passes value[0] instead of the full value array to buildExtensionQuery for extension fields. For the between operator, RAQB stores inputs as [from, to], so the upper bound is silently dropped before the Elasticsearch range query is built.

The "search API not triggered" issue is a downstream consequence of the same bug — the broken query was structurally identical on every Apply click, so the isEqual guard short-circuited setQueryFilter. Fixing Vector 1 resolves Vector 2 automatically. No changes to AdvanceSearchProvider were needed.

Fix: 5-line change — introduced an isBetweenOp check that passes the full [from, to] array for between/not_between and value[0] for all other operators (no regression).

Verified with unit tests

Image

mohitjeswani01 avatar Apr 19 '26 10:04 mohitjeswani01

Hi @Rohit0301 @chirag-madlani,

I'd like to work on this issue. I've done a deep technical analysis and reproduced the bug locally. Here's my understanding and proposed fix:

Root Cause Analysis:

The bug is in openmetadata-ui/src/main/resources/ui/src/utils/QueryBuilderElasticsearchFormatUtils.js, specifically in the buildEsRule() function (around line 939-946). When handling extension (custom property) fields, the code passes value[0] to buildExtensionQuery() — but for the between operator, RAQB stores the range as a flat array [from, to]. This means value[1] (the upper bound) is silently dropped before the Elasticsearch range query is built.

Why Bug #2 happens (search API not triggered): The malformed query (missing upper bound) is structurally identical on every Apply click, so the isEqual guard in AdvanceSearchProvider's setQueryFilter short-circuits — the API call never fires because the query hasn't "changed." Fixing the range bounds automatically resolves this secondary issue.

Proposed Fix (minimal, targeted):

// In buildEsRule(), before calling buildExtensionQuery():
const isBetweenOp = ['between', 'not_between'].includes(op);

return buildExtensionQuery(
  extensionPropertyName,
  entityType,
  isBetweenOp ? value : value[0],  // pass full [from, to] for range operators
  op,
  not,
  omPropertyType
);

This ensures buildExtensionQuery() receives the complete [from, to] array for between/not_between, while all other operators continue receiving value[0] (no regression). The downstream buildNestedTypedQuery() already handles range arrays correctly with gte/lte.

Testing plan:

  • Unit tests verifying between [5, 20] produces {gte: 5, lte: 20} in the nested range query
  • Unit tests for not_between with correct must_not wrapping
  • E2E validation against the Advanced Search UI with number custom properties

I have experience with React, Elasticsearch query DSL, and the RAQB library. I can deliver a clean PR with tests quickly.

Could you please assign this to me? Thank you!

yubarajDas avatar Apr 20 '26 08:04 yubarajDas

@Rohit0301 @PubChimps

Hi! I'd love to work on this issue and would like to get assigned to it. 🙋

I have gone through the issue description carefully and I'm confident I can tackle it effectively. I'm actively contributing to OpenMetadata and this looks like a great fit for me.

Could you please assign this issue to me? Thank you! 🚀

manavmax avatar Apr 20 '26 18:04 manavmax

@mohitjeswani01 I have assigned this issue you

Rohit0301 avatar Apr 24 '26 05:04 Rohit0301

@mohitjeswani01 I have assigned this issue you

@Rohit0301 thanks a lot for assigning the issue i will update you shortly on the merge conflict!🙏

mohitjeswani01 avatar Apr 24 '26 07:04 mohitjeswani01