Closed (fixed)
Project:
Search API Autocomplete
Version:
8.x-1.x-dev
Component:
General code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
27 Jan 2014 at 17:13 UTC
Updated:
1 Aug 2021 at 12:29 UTC
Jump to comment: Most recent
Comments
Comment #1
f0ns commentedIn terminal I can see solr found results but on screen nothing happens.
I guess this is a front-end JS issue? if you inspect and compare the html on the searchpage/search block with the html of the exposed form in blocks it's kinda different.
I'll have a quick look cause I also need this to work on exposed form blocks.
edit: Haven't found the cause of this issue yet.. anyone else has suggestions on how to resolve this? Thank in advance!
Comment #2
dotidentity commentedDid you select your view in the search-api index?
-> admin/config/search/search_api -> edit -> autocomplete tab?
Comment #3
f0ns commentedYes, all my views exposed form in block are selected in the autocomplete tab and it doesn't work. On every page (from search_api_page module) it works perfectly.
Comment #4
pix_ commentedI too have an exposed form block in the homepage and everything is working beautifully. i'm using the 1.0.
Comment #5
f0ns commentedPix, is this exposed form block made with views? Or are you just using the exposed form block for from you search page?
Everything works here except the exposed form blocks made with views, something goes wrong here with the auto complete functionality.
Comment #6
lammensj commentedThis might be a long shot but it worked on my project; did you try putting an id on the input element?
Comment #7
pmichelazzoThe same situation for me. Using a exposed form the autocomplete doesn't work.
Comment #8
pmichelazzoOps, I make a mistake (and could be yours too f0ns)
This module give a new permission in permissions list. When I check the roles to use the autocomplete and check the exposed block from a view, the things running well.
Thanks
Comment #9
f0ns commentedI will look into this later today. Need to check if this resolves the issue
Comment #10
pix_ commentedf0ns,
the exposed block is made with views and it is generated by my search page. It's a "real" block placed in a specific region on every page.
Be sure to enable and select a field to use for you autocomplete suggestions under
admin/config/search/search_api/index/product_display/autocomplete/YOURINDEX/edit
Comment #11
drunken monkeySorry, I could not reproduce this. It might be a problem with block caching, though, if you have that enabled. I'm not sure, but it might lead to the necessary Javascript not incldued on the page. Please see the source code of your page and check whether it includes the
…/search_api_autocomplete/search_api_autocomplete.jsJavascript file.Comment #12
f0ns commentedStill have this issue. All works except exposed blocks that come from views.
Comment #13
drunken monkeyAs said:
Comment #14
f0ns commentedJS is included on the page. I see the throbber moving but nothing is shown. Back-end of Solr shows x amount of hits.
Nothing is cached atm on the website.
I'll debug it further to find the cause.
edit: Still haven't found the issue here, the javascript answer is always empty, solr back-end shows my page has hits
When I search for "Down" in my global search exposed block I get answer:
{"Download":"\u003Cdiv class=\u0022search-api-autocomplete-suggestion\u0022\u003E\u003Cspan class=\u0022autocomplete-user-input\u0022\u003EDown\u003C\/span\u003E\u003Cspan class=\u0022autocomplete-suggestion-suffix\u0022\u003Eload\u003C\/span\u003E\u003C\/div\u003E"}When I search for "Down" on my views exposed blocks:
(empty)I checked every remark in this post and everything is setup as told. Also tested with 1.0 and 1.0-dev, same results
Comment #15
saseedharan commentedRecently i am also facing the similar issue in Drupal 8.7.5. We are using Exposed form as a Block and included it into the page using layout builder. I could able to see the suggestions but after choosing some suggestion
Here i am sharing more details. We using a module https://www.drupal.org/project/views_block_filter_block to make Exposed filters as a Block. And we adding those blocks into different sections in layout builder.
Comment #16
drunken monkeyIf it works fine with other views, and exposed form blocks based on Page displays, then probably the
views_block_filter_blockmodule is at fault. Have you tried with other setups?Furthermore, do you mean to say that the behaviors are not applied for some elements on the page? It’s clear that, if an AJAX callback returns just the view listing, then the autocomplete behavior won’t be applied to that. But the behavior should have been applied to the rest of the page, including the input field, before that. If not, that seems like a different problem altogether.
Can you confirm that
Drupal.behaviors.searchApiAutocomplete()is called more than once in this case? If the input field is there on the page, along with the right attributes, then it should be found in at least one of these calls.Comment #17
drunken monkeyAlso, in the future, it’s usually better to open a new issue instead of reviving a six-year-old one – especially if the old one didn’t seem to be going anywhere.
Comment #18
herczogzoltanI am still facing the same issue @f0ns has. What I did:
1. I created a Views page with views exposed form in block
2. I edited the admin/config/search/search_api/index/product_display/autocomplete/MYINDEX/edit to use the previous views page
3. I placed the views block on the site
4. I can see the throbbler being busy, but throws a 500 with the following error log in watchdog:
Symfony\Component\Routing\Exception\RouteNotFoundException type: Route "search_api_page.hu.my_view_machine_name" does not exist. message Drupal\Core\Routing\RouteProvider->getRouteByName() function.Comment #19
herczogzoltanLooks like the problem was on my side, I share my experience in case someone has the same case.
TL;DR: It should've been working at the first place, but an alter hook made the request failing.
Moral of the story is, always check your error messages, search for the anomalys in your custom code base or contributed modules you use system wide and also try the module on a clean Drupal install.
Now we have a working solution for:
- We have a block placed on the page which uses a views and the autocompletion uses that as well, and it works.
How we did it?
Prerequisites:
- search_api installed and configured
- search_api_autocomplete installed and the user you're testing with has the correct permissions
- You have a working index for the content you want to use in the autocomplete
And this works for us, hope it help for others as well. Spread the love! <3 Thanks for this awesome module!
Comment #20
golddragon007 commentedI have now a similar issue, I had to update the site's ancient modules where this worked perfectly, and when I did it break. We using here BEF (I don't know how much it relates to the issue). What I was able to find out until now, that inside the search_api_autocomplete_form_views_exposed_form_alter the type textfield was changed to search_api_autocomplete. This is good, but not enough as the processors remain the Textfield one, therefore the SearchApiAutocomplete::processSearchApiAutocomplete is never being called. As result, I don't have the functionality (library and working autocomplete) even, if the markup looks like an autocomplete field...
In the end I had to do something like this to fix the issue, but it's not correct and it's far from perfect:
I don't understand what needs to swap the process array on the form element, but it's clear that changing just the element type is not enough.
Comment #21
drunken monkey@ golddragon007: This seems like the exact same issue as #3159000: Autocomplete broken on views with Better Exposed Filters. Please try with the latest dev release. (I guess I should create a new stable release soon, too.)
Marking as fixed here. This issue can have so many different causes that it’s pretty useless discussing such different problems in the same issue. For future issue reports, please try to find out a bit more about why this fails before creating a new issue (like the last few commenters here did).