Due to #2278737: Combine Fulltext Search views filter that contains both all of these words filter and none of these words filter, I realized our method for transforming complex/nested keys arrays into Solr syntax still doesn't work in all situations. I therefore copied over the tests from the DB Search module, adapted them accordingly and really, there were a few fails. Not only did a query with complex keys have wrong results – we also still don't use the filter tags system to work correctly with OR facets.

Comments

drunken monkey’s picture

Status: Active » Needs review
StatusFileSize
new21.72 KB
new3.28 KB

Attached is both a patch for these problems and a patch containing the test I've used. It just assumes there is a Solr server running at http://localhost:8983/solr/ and uses that for the tests.
We probably shouldn't add the test case to the module, though, as it won't be usable for a lot of sites – especially, on drupal.org.

drunken monkey’s picture

Status: Needs review » Fixed

  • drunken monkey committed 5396fc2 on 7.x-1.x
    Issue #2290601 by drunken monkey: Fixed handling of complex keywords and...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

jaydub’s picture

Status: Closed (fixed) » Active

I just tested out an upgrade of Search API Solr to the latest version and a previously working search with OR facets now results in a failed Solr search with errors in Solr log after upgrading to 1.6. I've narrowed the set of changes from 1.5 to 1.6 to this particular change. If I swap out the 1.5 and 1.6 versions of includes/service.inc I am able to go from working to non-working to working search with facets.

In my particular case I am searching on a string 'superbad' with a drupal node type OR facet. If I search with just one type facet (e.g. 'csm_review') I am fine. As soon as I apply a second type OR facet (e.g. 'csm_video') I get the failure. This particular set of steps works fine with the 1.5 version of service.inc and returns valid results.

URI of the request:

/search/superbad?f[0]=type%3Acsm_review&f[1]=type%3Acsm_video

That is the URL generated by Facet API.

I am running Search API 7.x-1.13, Facet API 7.x-1.5 against Solr 3.6.x

Here is what shows up in the logs:

Sep 11, 2014 3:45:13 PM org.apache.solr.common.SolrException log
SEVERE: org.apache.solr.common.SolrException
	at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:134)
	at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:165)
	at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:129)
	at org.apache.solr.core.SolrCore.execute(SolrCore.java:1376)
	at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:365)
	at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:260)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)
	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:767)
	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
	at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
	at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at org.mortbay.jetty.Server.handle(Server.java:326)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: org.apache.lucene.queryParser.ParseException: Cannot parse '(({!tag=facet:type}ss_type:"csm_review") OR ({!tag=facet:type}ss_type:"csm_video"))': Encountered " "}" "} "" at line 1, column 18.

And here is what looks like the full call to Solr in the logs:

INFO: [core2] webapp=/solr path=/select params={spellcheck=true&facet=true&f.im_field_reference_review_ent_prod$field_term_tv_networks.facet.limit=50&sort=score+desc,+ds_created+desc&facet.limit=10&f.im_field_reference_review_ent_prod$field_term_book_publishers.facet.limit=50&f.im_field_reference_review_ent_prod$field_term_music_labels.facet.limit=50&f.ss_field_reference_review_ent_prod$type.facet.limit=-1&fl=item_id,score&f.im_field_reference_review_ent_prod$field_term_movie_studios.facet.limit=50&f.ss_type.facet.limit=-1&f.im_field_reference_review_ent_prod$field_term_ent_prod_awards.facet.limit=50&f.ss_field_reference_review_ent_prod$type.facet.mincount=0&f.is_field_reference_review_ent_prod$field_term_app_publishers.facet.limit=20&facet.field=is_field_reference_review_ent_prod$field_term_game_publishers&facet.field=im_field_reference_review_ent_prod$field_term_movie_studios&facet.field=im_field_reference_review_ent_prod$field_term_tv_networks&facet.field=is_field_reference_review_ent_prod$field_term_app_publishers&facet.field=is_field_reference_review_ent_prod$field_term_book_type&facet.field=im_field_reference_review_ent_prod$field_term_book_publishers&facet.field=im_field_reference_review_ent_prod$field_term_music_labels&facet.field={!ex%3Dfacet:type}ss_type&facet.field={!ex%3Dfacet:field_reference_review_ent_prod:type}ss_field_reference_review_ent_prod$type&facet.field=im_field_reference_review_ent_prod$field_term_ent_prod_awards&fq=(({!tag%3Dfacet:type}ss_type:"csm_review")+OR+({!tag%3Dfacet:type}ss_type:"csm_video"))&fq=index_id:"site_search_index"&facet.missing=false&f.ss_type.facet.mincount=0&facet.mincount=1&qf=tm_body$value^1.0&qf=tm_field_any_good$value^1.0&qf=tm_field_blog_body$value^1.0&qf=tm_field_blog_subhead^1.0&qf=tm_field_ed_blog_body$value^1.0&qf=tm_field_ed_blog_subhead^1.0&qf=tm_field_editors_pick_description$value^1.0&qf=tm_field_family_topics$value^1.0&qf=tm_field_field_topic_intro$value^1.0&qf=tm_field_one_liner$value^1.0&qf=tm_field_parents_need_to_know$value^1.0&qf=tm_field_press_release_body$value^1.0&qf=tm_field_press_release_subtitle^1.0&qf=tm_field_reference_review_ent_prod$field_term_app_platforms$name^1.0&qf=tm_field_reference_review_ent_prod$field_term_book_authors$name^2.0&qf=tm_field_reference_review_ent_prod$field_term_book_illustrators$name^2.0&qf=tm_field_reference_review_ent_prod$field_term_game_platforms$name^1.0&qf=tm_field_reference_review_ent_prod$field_term_movie_actors$name^2.0&qf=tm_field_reference_review_ent_prod$field_term_movie_directors$name^2.0&qf=tm_field_reference_review_ent_prod$field_term_music_artists$name^2.0&qf=tm_field_reference_review_ent_prod$field_website_url$url^2.0&qf=tm_field_reference_review_ent_prod$title^5.0&qf=tm_field_reference_review_lr$field_how_parents_help$value^1.0&qf=tm_field_reference_review_lr$field_term_skills$name^1.0&qf=tm_field_reference_review_lr$field_term_skills$parent$name^1.0&qf=tm_field_reference_review_lr$field_term_subjects$name^1.0&qf=tm_field_reference_review_lr$field_term_subjects$parent$name^1.0&qf=tm_field_reference_review_lr$field_what_kids_learn$value^1.0&qf=tm_field_research_author^1.0&qf=tm_field_research_intro$value^1.0&qf=tm_field_research_teaser_txt^1.0&qf=tm_field_term_blog_tags$name^1.0&qf=tm_field_term_ed_blog_categories$name^1.0&qf=tm_field_term_video_topics$name^1.0&qf=tm_field_term_video_type$name^1.0&qf=tm_field_top_picks_content$field_reference_review_ent_prod$title^1.0&qf=tm_field_top_picks_intro_text$value^1.0&qf=tm_field_top_picks_teaser$value^1.0&qf=tm_field_topic_question_answer$value^1.0&qf=tm_field_video_teaser$value^1.0&qf=tm_field_what_is_story$value^1.0&qf=tm_title^5.0&json.nl=map&wt=json&rows=20&start=0&facet.sort=count&q=superbad&f.is_field_reference_review_ent_prod$field_term_book_type.facet.limit=50&f.is_field_reference_review_ent_prod$field_term_game_publishers.facet.limit=50} status=400 QTime=4

And the same full call output in the logs using 1.5:

INFO: [core2] webapp=/solr path=/select params={spellcheck=true&facet=true&f.im_field_reference_review_ent_prod$field_term_tv_networks.facet.limit=50&sort=score+desc,+ds_created+desc&facet.limit=10&f.im_field_reference_review_ent_prod$field_term_book_publishers.facet.limit=50&f.im_field_reference_review_ent_prod$field_term_music_labels.facet.limit=50&f.ss_field_reference_review_ent_prod$type.facet.limit=-1&fl=item_id,score&f.im_field_reference_review_ent_prod$field_term_movie_studios.facet.limit=50&f.ss_type.facet.limit=-1&f.im_field_reference_review_ent_prod$field_term_ent_prod_awards.facet.limit=50&f.ss_field_reference_review_ent_prod$type.facet.mincount=0&f.is_field_reference_review_ent_prod$field_term_app_publishers.facet.limit=20&facet.field=is_field_reference_review_ent_prod$field_term_game_publishers&facet.field=im_field_reference_review_ent_prod$field_term_movie_studios&facet.field=im_field_reference_review_ent_prod$field_term_tv_networks&facet.field=is_field_reference_review_ent_prod$field_term_app_publishers&facet.field=is_field_reference_review_ent_prod$field_term_book_type&facet.field=im_field_reference_review_ent_prod$field_term_book_publishers&facet.field=im_field_reference_review_ent_prod$field_term_music_labels&facet.field={!ex%3Dss_type}ss_type&facet.field={!ex%3Dss_field_reference_review_ent_prod$type}ss_field_reference_review_ent_prod$type&facet.field=im_field_reference_review_ent_prod$field_term_ent_prod_awards&fq={!tag%3Dss_type}((ss_type:"csm_review")+OR+(ss_type:"csm_video"))&fq=index_id:"site_search_index"&facet.missing=false&f.ss_type.facet.mincount=0&facet.mincount=1&qf=tm_body$value^1.0&qf=tm_field_any_good$value^1.0&qf=tm_field_blog_body$value^1.0&qf=tm_field_blog_subhead^1.0&qf=tm_field_ed_blog_body$value^1.0&qf=tm_field_ed_blog_subhead^1.0&qf=tm_field_editors_pick_description$value^1.0&qf=tm_field_family_topics$value^1.0&qf=tm_field_field_topic_intro$value^1.0&qf=tm_field_one_liner$value^1.0&qf=tm_field_parents_need_to_know$value^1.0&qf=tm_field_press_release_body$value^1.0&qf=tm_field_press_release_subtitle^1.0&qf=tm_field_reference_review_ent_prod$field_term_app_platforms$name^1.0&qf=tm_field_reference_review_ent_prod$field_term_book_authors$name^2.0&qf=tm_field_reference_review_ent_prod$field_term_book_illustrators$name^2.0&qf=tm_field_reference_review_ent_prod$field_term_game_platforms$name^1.0&qf=tm_field_reference_review_ent_prod$field_term_movie_actors$name^2.0&qf=tm_field_reference_review_ent_prod$field_term_movie_directors$name^2.0&qf=tm_field_reference_review_ent_prod$field_term_music_artists$name^2.0&qf=tm_field_reference_review_ent_prod$field_website_url$url^2.0&qf=tm_field_reference_review_ent_prod$title^5.0&qf=tm_field_reference_review_lr$field_how_parents_help$value^1.0&qf=tm_field_reference_review_lr$field_term_skills$name^1.0&qf=tm_field_reference_review_lr$field_term_skills$parent$name^1.0&qf=tm_field_reference_review_lr$field_term_subjects$name^1.0&qf=tm_field_reference_review_lr$field_term_subjects$parent$name^1.0&qf=tm_field_reference_review_lr$field_what_kids_learn$value^1.0&qf=tm_field_research_author^1.0&qf=tm_field_research_intro$value^1.0&qf=tm_field_research_teaser_txt^1.0&qf=tm_field_term_blog_tags$name^1.0&qf=tm_field_term_ed_blog_categories$name^1.0&qf=tm_field_term_video_topics$name^1.0&qf=tm_field_term_video_type$name^1.0&qf=tm_field_top_picks_content$field_reference_review_ent_prod$title^1.0&qf=tm_field_top_picks_intro_text$value^1.0&qf=tm_field_top_picks_teaser$value^1.0&qf=tm_field_topic_question_answer$value^1.0&qf=tm_field_video_teaser$value^1.0&qf=tm_field_what_is_story$value^1.0&qf=tm_title^5.0&json.nl=map&wt=json&rows=20&start=0&facet.sort=count&q=superbad&f.is_field_reference_review_ent_prod$field_term_book_type.facet.limit=50&f.is_field_reference_review_ent_prod$field_term_game_publishers.facet.limit=50} hits=31 status=0 QTime=6

Looks like more or less the difference are these two parameters:

1.5

&facet.field={!ex%3Dss_type}ss_type&facet.field={!ex%3Dss_field_reference_review_ent_prod$type}ss_field_reference_review_ent_prod$type

&fq={!tag%3Dss_type}((ss_type:"csm_review")+OR+(ss_type:"csm_video"))

1.6

&facet.field={!ex%3Dfacet:type}ss_type&facet.field={!ex%3Dfacet:field_reference_review_ent_prod:type}ss_field_reference_review_ent_prod$type

&fq=(({!tag%3Dfacet:type}ss_type:"csm_review")+OR+({!tag%3Dfacet:type}ss_type:"csm_video"))

Sorry if I'm not providing enough detail here but I'm not familiar with the changes in this patch and the concept of tags & filters.

drunken monkey’s picture

Status: Active » Needs review
StatusFileSize
new1.26 KB
new22.88 KB

Wow, thanks for providing so much detail and analysis! With that, it was very easy to see why this failed, and I could also easily reproduce it. The attached patch should fix the problem, please test!

The reason this previously slipped past me is probably that Solr 4.x seems to handle that error more gracefully, just ignoring the misplaced tags instead of throwing an exception (as 3.x seems to do). But I could still see that there were no more facets returned when more than one OR facet was active.

I also updated the module's (unofficial) test to check for this case.

jaydub’s picture

Status: Needs review » Reviewed & tested by the community

Ok finally got time to test the patch in #6 and the page no longer WSOD and the search results with the multiple OR facets are correct and match to the behaviour in the previous release of the module.

Frederic wbase’s picture

I've also tested the patch from #6 and it works like a charm now!
Thanks for your hard work guys!

garrettc’s picture

I can also confirm that the patch from #6 fixed the issue for me on Solr 3.6.

spadxiii’s picture

Just applied this to 1.6 and it works like a charm!

My error was with node-type as a facet, I couldn't select more than 1 value.

drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Excellent, good to hear. Thank you all for testing!
Committed.

  • drunken monkey committed c62ad8e on 7.x-1.x
    Follow-up to #2290601 by drunken monkey: Fixed handling of complex...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

Exploratus’s picture

This problem was driving me CRAZY! Couldn't get Range facets to work with OR, and use multiple facets of the same field. Now I can! Thanks!

rp7’s picture

I have a facet (called "document_type) using the OR operator (with only 1 active item allowed) because I would like the counts for the non-active items to remain visible. When upgrading to 7.x-1.6, this stopped working. The non-active items stopped appearing. Upgrading to the latest 7.x-1.x-dev didn't solve this either. I *think* this issue is what broke it, since the fq filter is not being tagged anymore.

If I compare the params sent to Solr:
facet.field > {!ex=facet:document_type}ss_document_type
fq > ss_document_type:"article"

When it should be:
facet.field > {!ex=facet:document_type}ss_document_type
fq > {!tag=facet:document_type}ss_document_type:"article"

Is this issue specific to my installation, or are other people seeing the same? Didn't have the time yet to test this on a clean installation, might do so if needed.

gaëlg’s picture

Tricky bug. This might deserve a new stable release. ;)

daluxz’s picture

Status: Closed (fixed) » Active

I have the same issue as RaF7.
We have a facet using an OR-filter and since the update to 7.x-1.6 this facet stopped working correctly. Only active facet-links are shown. All other facet-links are not visible any more.

Reverting the code that was changed in the protected function getFacetParams in service.inc makes the facet-links visible again.

daluxz’s picture

StatusFileSize
new2.03 KB

Added a patch that reverts the code as mentioned in #17.

daluxz’s picture

StatusFileSize
new2.44 KB

Another search_api view had a similar problem, which needed even more code to be reverted.
See attached patch. Basically the same as #18, but with more code reverted.

drunken monkey’s picture

Are you maybe using an old version of Search API? I.e., older than 1.10? In that case, please update to keep this working for Solr.

daluxz’s picture

No, the sites we are experiencing these problems with are all using the most recent version of Search API (currently 7.x-1.14)

drunken monkey’s picture

Status: Active » Postponed (maintainer needs more info)

And you are using the latest dev version of Search API Solr?
Which Solr version are you using?
Can you provide more detailed instructions on how to reproduce?

I just tried again, setting the "Author" facet to "OR" on a node index, and it worked fine.

daluxz’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

We are using Search API Solr 7.x-1.6.
Solr version 3.6.1
Taxonomy facet using OR on a node index.
I was pretty sure that the dev-version had the same problem, but a quick test proves me wrong. Using the dev-version the problem seems to be gone.

I now see that the patch in #6 got committed later (#12) and is missing from 1.6. Applying that patch on the 1.6-version fixes my problem.

Thanks for looking into this.