REST datasource filter set search not working

  • 1
  • Problem
  • Updated 3 months ago
  • Solved
  • (Edited)
I have a rest datasource pointing to bitbucket with a query like so:

/repositories/compasscare/optimizecore/issues?q=((state={{state1}}+OR+state={{state2}}+OR+state={{state3}}+OR+state={{state4}}){{#search}}+AND+(content.raw~{{search}}+OR+title~{{search}}){{/search}})&sort={{sort}}

I counldn't figure out how to make a 'conditional AND' work with a datasource query. Deactivating a condition in skuid doesn't change the url that's being passed, so it was confusing bitbucket, so I went with the merge syntax.

I have a filter set on the model with search properties like so:


When I run the page and type anyting in the search bar, skuid is inserting 0 into the {{search}} instead of what I'm actually searching (according to the request payload data):

"https://api.bitbucket.org/2.0/repositories/compasscare/optimizecore/issues?q=((state=%22new%22+OR+state=%22open%22+OR+state=%22%22+OR+state=%22%22)+AND+(content.raw~0+OR+title~0))&sort=""

But apparently it's not inserting 0 into {{#search}}, becuase it's processing the conditional merge correctly.

Help?
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb

Posted 5 months ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
10.0.25
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Looks like conditional merge syntax works just fine for filtered conditions. I added this to the query...

{{#kind}}+AND+kind={{kind}}{{/kind}}

Filtering "kind" to "bug" with a select filter in runtime has the desired result, with the payload data url

+AND+kind=%22bug%22+
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
bump!!
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Anyone out there have an idea how I can get the search to work?
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Sodium Sodium
Sodium Sodium
Sodium Sodium
Sodium Sodium

Sodium Sodium
Sodium Sodium
Sodium Sodium
Sodium Sodium
BATMAN!



(also, bump)
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Commence daily bumps until resolution.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
bump
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
bump #5
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
bump #6
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
bump #7

#persistentwidow
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
bump #8


Really, Skuid? this is getting pretty embarrassing...
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
bump #9
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
bump #10
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
This thread has been marked "in progress", but as far as I can tell, no progress has been made here.

I'm a fairly patient man, but my patience is wearing thin.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
bump #11
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
bump #12
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Just re-read the OP and realized that the last word before "Help?" should be 'incorrectly.'
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
bump #13
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Hey Matt. I can get my REST expert to give you a hand. No charge. Lemeno
(Edited)
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Thanks, Pat. Maybe this is a REST issue, but the problem I'm seeing is that skuid is putting 0 in for the {{search}} merge, rather than the actual search term that I enter in the skuid table's search bar.

I think if the merge syntax worked as expected, I wouldn't have any REST problems.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Got it. Lemeno
Photo of Mark DeSimone

Mark DeSimone, Official Rep

  • 11,050 Points 10k badge 2x thumb
Hi Matt,

I hear your frustration, and I apologize that it's taken so long for a response to come to this topic. I also see that Pat just responded as well, which is comforting, knowing his level of expertise and experience. I will be happy to join this conversation as well to find a root cause and work towards a solution. Since your reported issue involves a few layers of complexity, at a glance I'm not sure which piece I should be most suspicious of. But it sounds like you suspect that the merge variable for {{search}} is not behaving as expected. Have you found that this is only happening when you try to use it with REST data sources?

The fact that a zero is getting inserted makes me wonder - perhaps the 0 is coming into the picture because it's the first item (item 0, if zero-indexed) in the JSON underneath... One obvious sanity check to make - have you tried triple mustaches around search, instead of double mustaches?

Ideally I'd like to boil this down as much as possible so if there's a product issue at work, we'll be able to understand what's relevant for reproducing the issues. 

Have you tried a simple test of having the {{search}} by itself in the REST query? I know it would probably throw an error, but it would be helpful to see how things behave when that merge variable is by itself. 
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Mark,

Thanks for jumping in.

I'll do my best to simplify.

First, I tried to reduce the  data source url to 
/repositories/compasscare/optimizecore/issues{{#search}}?q=title~{{search}}{{/search}}

My search bar is on a filter set on the model. When no search is entered, the request payload data url is https://api.bitbucket.org/2.0/repositories/compasscare/optimizecore/issues, as expected.

When I enter anything in the search, the data url is 
https://api.bitbucket.org/2.0/repositories/compasscare/optimizecore/issues?q=title~0
Where 0 is being entered for the {{search}} merge. Something other than 0 seems to be getting passed to the {{#search}} conditional merge syntax, though, because the contents between {{#search}} and {{/search}} are being evaluated (unless 0 counts?).

Triple mustache yields the same result.

Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Next, I tried to simplify the data source url further, to

/repositories/compasscare/optimizecore/issues?q=title~{{search}}

I found that the source was returning [Object object], until I put quotes around the search, which leaves me with a data source url like this:

/repositories/compasscare/optimizecore/issues?q=title~"{{search}}"

That actually worked as expected!!!!


(Edited)
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Now, the trick is to work backwards to get all the conditions back in there as needed.

When I tried a data source url like this:

/repositories/compasscare/optimizecore/issues{{#search}}?q=(content.raw~"{{search}}"+OR+title~"{{search}}"){{/search}}

I got the 0 again for {{search}}.

So, the issue clearly has something to do with the interaction between the conditional merge syntax and the regular merge syntax. 

I dropped the conditional merge syntax, and went with this
/repositories/compasscare/optimizecore/issues?q=(content.raw~"{{search}}"+OR+title~"{{search}}")

And it worked again!
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Implementing those same changes back into our larger data source url, and we're in business... the final (WORKING :) ) url is:

/repositories/compasscare/optimizecore/issues?q=((state={{state1}}+OR+state={{state2}}+OR+state={{state3}}+OR+state={{state4}}){{#kind}}+AND+kind={{kind}}{{/kind}}{{#user}}+AND+assignee.username="{{user}}"{{/user}}+AND+(content.raw~"{{search}}"+OR+title~"{{search}}"))&sort={{sort}}


So, I'm good to go, in that I've found a workaround that gets my page where it needs to be.