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
I'll try it if you provide
I'll try it if you provide enough info to reproduce your view.
Reproduce
Should I paste the export?
You can try, or you can just
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.)?
The view retrieves a list of
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:
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
It is a page display with a
Are you sure that you have selected this display when you try the preview?
Unless there's some place
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
It seems I have reproduce the
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?
Oh, interesting. If I change
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
This view is querying a solr
How did you implement this?(maybe this is the reason that preview doesn't work?).
It looks like we can enter
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
Ach. I can't use "Query
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
Oh man. There's a hook -
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.
So I found this:
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...
Could you share the code of
Could you share the code of that hook.
It doesn't appear to be
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.
So the answer to the original
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!