Looker API 4.0 filter expressions - Stack Overflow

admin2025-04-29  2

I'm building an aggrid based on looker data and using the API v4.0. I've successfully gotten serverside sorting working but filtering is causing me issues. For the project, I am using Looker Open-Source Filter Components () to generate my filter expressions.

For example: I entered starts with 123 and got 123% contains John %John%

I was expecting to use those in an inline query at the endpoint: https://${baseUrl}/api/4.0/queries/run/json_detail

Inline Query

{
  view: "fct_rx_dispenses_clear_view",
  fields: [
    "fct_rx_dispenses_clear_view.total_dispensed",
    "fct_rx_dispenses_clear_viewpany",
    "fct_rx_dispenses_clear_view.unique_patients_count",
    "fct_rx_dispenses_clear_view.total_unique_dispenses",
    "fct_rx_dispenses_clear_view.total_unique_patients",
    "fct_rx_dispenses_clear_view.data_source",
    "fct_rx_dispenses_clear_view.dispensed",
    "fct_rx_dispenses_clear_view.brand",
    "fct_rx_dispenses_clear_view.date_extracted_date",
  ],
  fill_fields: null,
  filters: {
    "fct_rx_dispenses_clear_view.brand": "Met%",
  },
  filter_expression: null,
  sorts: [
    "fct_rx_dispenses_clear_view.data_source",
  ],
  limit: "1",
  column_limit: "10",

I expected this to be a filter that starts with Met but this query fails with a 400 error

{
    "message": "Invalid number filter syntax: \"Met%\"",
    "documentation_url": ".0/400/post/queries/run/:result_format"
}

The link mentions I might be able to use filter_expressions instead of filter but everything I've tried there results in a 400, or 500 error.

I guess the tldr; is how do I run a query for looker that filters with a starts_with, ends_with, contains, etc?

EDIT: Turns out the answer was in my question. The filter type was wrong. I was trying to search for a string when aggrid thinks the fields is a number.

转载请注明原文地址:http://anycun.com/QandA/1745938093a91379.html