Hi

I am playing around with solr and views3. My first view with solr has an exposed search filter.
The exposed filter is not an autocomplete widget, but it would be great to have it the same autocomplete as the normal search box.

Mark it as a feature request, but there could be a way and I haven't find it yet.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

janusman’s picture

Status: Active » Needs review
FileSize
1.43 KB

Hmm, must be in a good mood today =) How about this patch?

Please test.

vanillawater’s picture

Hi,
Regarding the patch, I am getting apache2 logs :

PHP Fatal error: Cannot redeclare apachesolr_autocomplete_form_alter() (previously declared in ../sites/all/modules/apachesolr_autocomplete/apachesolr_autocomplete.module:45) in ../sites/all/modules/apachesolr_autocomplete/apachesolr_autocomplete.module on line 78, referer: http://../admin/settings/apachesolr/settings

Thank you in advance.

janusman’s picture

Please make sure you try it against a fresh download...

rjbrown99’s picture

I'm using the Apachesolr Views module, and I had to make an addition to the patch to get an exposed filter working on my site. The base_table for my view is apachesolr_node and not apachesolr, so I accounted for that in the if statement. This is the same patch as #1 with that addition to the if.

rjbrown99’s picture

The one thing I noticed with this patch is that the calculation for number of results seems to be incorrect. It may not be taking in to account the existing facet choices that may have already been made. For example, my left facet has "Category A" selected, where the search box just refines the results. I would expect autocomplete to only search "Category A" for "Keyword" and suggest say 10 results. Instead, it seems to do a global search on "Keyword" and suggests 100 results.

In the end the search works properly after submit - it only returns the 10 results. However the numeric calculation for number of results was wrong. I hope that makes sense.

janusman’s picture

Status: Needs review » Needs work

Re: #5: yeah, in fact that can also be reproduced by using the "Retain current filters" on the /search/apachesolr_search page... the reported # of results numbers might not be accurate since the active filters are not taken into account.

That, however is impossible using the Drupal core taxonomy widget, but might be with the new custom JS widget.

A workaround for now is to copy the theming functions over to your theme and making those not show the result counts.

Leaning towards a simple solution: allow admins to switch off counts using the admin UI. That would get this patch through to enable support for Views 3. Marking as "needs work" for now.

Ideas, patches, feedback welcome =)

N1ce0ne’s picture

Issue tags: +Apache Solr Autocomplete Field
FileSize
12.66 KB

Hello,

I have installed the Patch "apachesolr_autocomplete-719382-4.patch" the Patch works fine, i can see the little clock that autocomplete looking for something but there are no results.If I search with Apache Solr search the autocomplete works.

Can you help me pls?

Regards

Equinger’s picture

I have the same problem as #7

Equinger’s picture

I corrected problem #7 by adding the following line:

$form[$id]['#attributes']['class'] .= ' apachesolr-autocomplete unprocessed';

Before, it was acting as a generic autocomplete form.

scotjam’s picture

#9 worked for me, no idea what it does any why I need it, but it works. Thanks for this.

But, I'm finding that when I click on a selection, the search query doesn't get updated with the selection. Instead the 'half' text that I entered to trigger the autocomplete is used as the query text. I'm using the new custom widget, which other than the above works fine.

Update.. problem above experience with FireFox 3.6, but IE7 and Opera 10 work just fine.

scotjam’s picture

Just a kind request...

Could the patch in #4 (in addition to the fix in #9) be included into the module?

cheers
scotjam

janusman’s picture

The patch from #9 did get in, see the diff here:

http://drupalcode.org/project/apachesolr_autocomplete.git/blobdiff/f3f06...

So switching over to analyzing the patch in #4... for now, could you (or someone) please re-roll the patch so that it applies to the current branch(es)? Because of this, leaving as "needs work".

Also, I'm really trying to keep the 6.x and 7.x branches in sync, but I have not checked how ApacheSolr Views for 7 is coming along, so that might offset the actual committing of the patch to the 7.x branch.

scotjam’s picture

FileSize
1.27 KB

Never worked with cvs before, so I manually apply patches.
But to give this a go, I've used diff. So beware! this is my first re-roll of a patch.

It's for 6.x-1.x-dev.
Hope this works / helps

dirtysteak’s picture

Tried patch in #13 and got no result.

Replacing line 100 of the .module file with:

$form[$id]['#attributes']['class'] .= ' apachesolr-autocomplete unprocessed';

did work, however.

We are running a bleeding edge setup, views 3, solr search 6.2. Seems to be working so far.

scotjam’s picture

That's weird,

I thought #9 was already in there, but it doesn't look like it does. I can't spot the line in the diff given in #12.

help.

janusman’s picture

Status: Needs work » Needs review

@scotjam: The new function apachesolr_autocomplete_do_alter() is now doing the concatenation of the extra class =)

Setting as needs review.

picxelplay’s picture

#13 + #14 works good, but, Facet blocks disappear after you click an autocomplete result.

puzl’s picture

whoops

janusman’s picture

Status: Needs review » Needs work

This will now need work since the patch will probably no longer apply.

alibama’s picture

Correction: works well with #14. Have pushed it to the repo below

hi all, tested against the latest release of solr views + autocomplete. The little ajaxy circle is there, but it doesn't actually do anything at this point am testing here, if anyone wants ownership am glad to share ;P
https://github.com/alibama/apachesolr-autocomplete-drupal

thanks for the great mod, latest patch below, am new with creating patches, so let me know what needs doing...

alibama’s picture

er, here's the patch, anyone testing it please let me know if it's straight

janusman’s picture

Status: Needs work » Needs review

Thanks @alibama, did you mean to set this as "needs review"?

alibama’s picture

@janusman = that's what i meant to say ;) thanks = yes, patch needs review, and if you would be so kind as to explain my mistakes so that I'll learn how to do this correctly next time it'd be most appreciated - also while this is a very simple module I've gone ahead and done a small write-up +vid documentation here

http://blog.hsl.virginia.edu/drupalpress/apachesolr-autocomplete-for-vie...

Thanks all for the great tools = much appreciated

janusman’s picture

Patch from #21 looks good. I'll do some testing and post back. (Also, need to see how this'll work in 7.x)

mike27’s picture

Any news about that in drupal 7?

mike

semanthis’s picture

For Drupal 7 just add the folloing code to apachesolr_autocomplete.module before these lines
"/**
* Helper function to do the actual altering of search forms."

/* Implementation of hook_form_FORM_ID_alter().
 *
 * Alter exposed forms of type keyword from views
 */
function apachesolr_autocomplete_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {
  if ($form['keyword']['#type'] = 'textfield'){
  $element = &$form['keyword'];
  apachesolr_autocomplete_do_alter($element, $form);
  }
}

Sorry for not sending a patch my module is already patched several times...

luo8’s picture

hello Alibama,all,
did you already setup somebody of you searching as you mentioned in #5?
I would like to use just one search block with autocomplete and "Retain current filters" support .
Currently after searching I could see exposed filters, if I checked(active) one of Taxonomy filter(f.e. cars) and do new search, I see results include all non active filters (flats,mobiles...) as well and there is problem I would like to see just result for specified current filters.
Alibama have implemented it in his site http://www.hsl.virginia.edu/...
Pls. could you help me somebody?
Thanks

luo8’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
alibama’s picture

hi luo8,
is your goal to implement this in D7? I'm not quite there yet, need to work on it - will keep an eye on this thread

luo8’s picture

alibama,
yes I working with D7.
On which version did you implemented it?
Are you using taxonomy,content type or fields filer?
Is posibility to have more filters?

Thanks

alibama’s picture

we are on d6 with content types, had a hard time getting more filters. am going to begin testing with d7 in the next few weeks and hope to have better answers then

luo8’s picture

hello alibama,
I believe you that was a hard time.
It's pitty that is not working with taxonomy terms,do you think that could be possible to make it functional with Taxonomy?
Do you have live page with more filter's working,may I see it?
Thanks.

aaronglamb’s picture

Status: Needs review » Patch (to be ported)
FileSize
1.17 KB

A patch for #26 above. Please test away.

luo8’s picture

Category: feature » bug
Status: Patch (to be ported) » Needs work

Dear all,
after "flush all caches" autocomplete module is unfunctional...
Why I can not use Retain current filters ? Is bug?

kevster’s picture

Im trying to get this working on latest dev version as I dont get the autocomplete circle showing.

I have a search view with a fulltext search exposed field on that works fine but not with autocomplete (exposed form in block). If I apply the patch in #26 I get an extra search field below the submit button for my first field and this does have an autocomplete circle.

If I type text in to the new field I get a list of relevant results back, then select one but my search result brings back all results (not filtered). Looking at the URL I see:
xxxx/solrsearch4?search_api_views_fulltext=&keyword=bergeon+each

If I change it to:
xxxx/solrsearch4?search_api_views_fulltext=bergeon+each&keyword=bergeon+each it works but its relying on both my search fields being populated with the same value?

Should my original search field be replaced with the new one using this patch?

orig field -

new field -

Any help would be much appreciated! Very useful module and great for a 10k product site, I think I must be 98% there...

Drupal 7.22
Apache Solr framework 7.x dev
Apache Solr search 7.x dev
Apache Solr Views Integration 7.x-1.0-beta2
Apachesolr Commerce 7.x-1.x-dev
Commerce 1.5

kevster’s picture

Sorry - attached screengrab showing both fields...

kevster’s picture

Ive managed to resolve my issue - because my exposed search field was not named keyword the patch added another search field. My tweaking the patch to target my exposed field name it all worked ok. This shouldnt be field name specific so Im assuming there is something wrong my end but at least I have it working now.

Its a great feature and definitely a big bonus from a UI perspective and also helping filter 10,000 prods ;-)

sylus’s picture

Attaching patch for latest dev.

alibama’s picture

This patch worked with the same relatively disastrous results mentioned above.... now all my exposed filters have an extra apachesolr autocomplete field in them... .ugh

alibama’s picture

would you mind posting some of the changes you've made to your autocomplete patch? I can't seem to get it running... Thanks

Robert Castelo’s picture

+++ b/apachesolr_autocomplete.module
@@ -479,3 +479,14 @@ function apachesolr_autocomplete_form_apachesolr_settings_alter(&$form, $form_st
+  if ($form['keyword']['#type'] = 'textfield') {

should be == instead of =

luo8’s picture

Hello,
make it functional you ca use another way as well...you need to install "Facet API Pretty Paths" module..

Robert Castelo’s picture

Note that the auto-complete does a site wide search for everything that's been indexed, it's not filtering the results by the filters that have been set up on the View.

So currently this is useless for anything except the site wide search.

pio.fernandes’s picture

The last patch was not working without a context variable.
I know this is an old one, but here's a new patch, it might help someone who uses apachesolr suite and not the search_api, like me.

pio.fernandes’s picture

pio.fernandes’s picture

melonangie’s picture

I got the error below when trying to apply patch #46. I just put it the code my self and created another patch from a fresh 7.x-1.x-dev.

can't find file to patch at input line 14
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|From 8fc26c1e915490e45ec41e9630342bb6f1f83d03 Mon Sep 17 00:00:00 2001
|From: piof <piofernandes@redweb.com>
|Date: Mon, 30 Jan 2017 16:58:59 +0000
|Subject: [PATCH] Apply the new function.
...