This is driving me nuts. Any help greatly appreciated!

I have a view with a contextual filter of type Content datasource: ID

When the value is NOT in the URL, I provide the following fixed value: ?search=

It is a page display with a path of /search

A typical query string is "/search?search=venice"

I am trying to replicate this query string in the View Preview

The instructions in the View Preview are: "Separate contextual filter values with a "/". For example, 40/12/10."

How do I modify "?search=venice" to fit into "40/12/10"?

Thanks

EDIT:

I'd like to add that /search?search=venice returns results when used on the site, but I cannot get it to return results when used in the Preview.

Here's something else I just noticed. When putting "?search=venice" in the "Preview with contextual filters:" text box, the path generated by the Preview is "/search/%3Fsearch%3Dvenice". This does not work as a query string on the site.  The extra "/" after the first "search" needs to be removed and the HTML-ASCII codes need to be converted to their respective characters.

Comments

wombatbuddy’s picture

I'll try it if you provide enough info to reproduce your view.

mmrtnt’s picture

Should I paste the export?

wombatbuddy’s picture

You can try, or you can just explain what its purpose is (what should it display)? 
For now, I don't understand how to reproduce it.
Is the problem exist only in preview mode or it not works in other displays (page, block etc.)?

mmrtnt’s picture

The view retrieves a list of properties based on their node #s.  Or, without a node #, it will query for their country or city.

So these are all valid queries:

/search/4095+1110
/search?search=italy
/search?search=los+angeles

This all works fine from the address bar in a browser,

What I can't get to work is ?search=italy in the view preview so that I can inspect the SQL.

Thank you

wombatbuddy’s picture

It is a page display with a path of /search

Are you sure that you have selected this display when you try the preview? 

mmrtnt’s picture

Unless there's some place specific that I need to go to set that, yes.

The contextual filter 1057 returns a property

The contextual filter ?search=venice returns all properties - as if there were no filter at all, when it should only return 4.

I've added a couple of screenshots to a Google Photo Album. The first is one with the NID as the filter, the second is with "?search=venice"

https://photos.app.goo.gl/avVh9d1K4mLTZ8CB6

wombatbuddy’s picture

It seems I have reproduce the issue you are talking about.
But I still can't understand why do you use the fixed value instead of 'Query parameter'?
See the screenshot:
https://cdn1.imggmi.com/uploads/2019/10/15/3f768fe9383fca413f054ba39eaee...

Could you share the screenshots of your filter configuration?

mmrtnt’s picture

Oh, interesting.  If I change that to query parameter, the NID search still works, but the ?search=venice search still returns all properties in preview, but shows a 404 in the browser

This view is querying a solr server - I apologize if I should have mentioned that earlier.

Here's a screenshot of the filter config

https://photos.app.goo.gl/DsazX4C9MtefmFBy9

wombatbuddy’s picture

This view is querying a solr server

How did you implement this?
(maybe this is the reason that preview doesn't work?). 

wombatbuddy’s picture

It looks like we can enter into the preview field only a filter values.
Therefore, in case of using 'Query parameter', you can input just the venice
but not ?search=venice

mmrtnt’s picture

Ach. I can't use "Query parameter" because it gives a 404 in the browser for ?search=venice and nothing for /venice and a count but no results for /1059

Trying "?search=venice" in Preview with "Query parameter" set gives us all results

Trying "venice" in Preview with "Query parameter" gives no results

mmrtnt’s picture

Oh man. There's a hook - search-form-alter.  I'm going to look at that in the debugger.

Sorry, I didn't write this code.  Just trying to figure out what's going on.

Thank you for all the help so far.

mmrtnt’s picture

So I found this:

"Search API does not show the query in views preview, which is a known bug."

https://drupal.stackexchange.com/questions/200984/how-do-print-the-query...

wombatbuddy’s picture

Could you share the code of that hook.

mmrtnt’s picture

It doesn't appear to be related.  What I've found is that the data is coming out of Solr, but getting lost in the processing prior to rendering.  I'm trying to use hook_view_pre_render to inspect the values.

mmrtnt’s picture

So the answer to the original question is - You can't see the body of search_api queries in views Preview.

Drupal 8.7.3
Search API 8.x-1.13

I was able to solve the actual problem (results missing in view) by running queries in the Solr dashboard, modifying the parameters until I got the results I wanted then comparing those parameters to the view fields.

Thanks @wombatbuddy!