Boosting results based on facet being in a particular field (other than the facet) with Solr and Drupal Search API Solr

Impossible to alter Solr “q” parameter [#2978694] | Drupal.org

Possible completely different approach

https://www.drupal.org/project/views_filters_populate

Idea of above module, could put the same query string in multiple fields at once, that could have their own boost?

Back to the suffering, forget how we got out of it

2021-08-28 06:18:59.151 INFO (qtp443721024-72) [ x:drupal] o.a.s.c.S.Request [drupal] webapp=/solr path=/select params={f.ss_virtual.facet.missing=false&bf=recip(abs(ms(NOW,ds_changed)),3.16e-11,.08,.05)&TZ=America/New_York&fl=,score&facet.missing=false&fq={!tag%3Dnonobsolete}(dm_dates_end:{“2021-08-28T06:18:59Z”+TO+}+(:+-dm_dates_end:[+TO+]))&fq=bs_status:“true”&fq={!tag%3Dfacet:services}sm_services:“Language+Instruction”&fq=%2Bindex_id:main&fq=ss_search_api_language:(“en”+“und”+“zxx”)&f.sm_ages.facet.missing=false&f.sm_services.facet.missing=false&f.ss_types.facet.missing=false&f.sm_activities.facet.missing=false&f.sm_neighborhoods.facet.missing=false&wt=json&facet.field={!key%3Dss_types+ex%3Dfacet:types}ss_types&facet.field={!key%3Dsm_neighborhoods+ex%3Dfacet:neighborhoods}sm_neighborhoods&facet.field={!key%3Dss_virtual+ex%3Dfacet:virtual}ss_virtual&facet.field={!key%3Dsm_cost_subsidies+ex%3Dfacet:cost_subsidies}sm_cost_subsidies&facet.field={!key%3Dsm_activities+ex%3Dfacet:activities}sm_activities&facet.field={!key%3Dsm_services+ex%3Dfacet:services}sm_services&facet.field={!key%3Dsm_ages+ex%3Dfacet:ages}sm_ages&json.nl=flat&f.sm_ages.facet.limit=50&f.sm_activities.facet.limit=50&start=0&f.sm_cost_subsidies.facet.missing=false&sort=score+desc&rows=25&f.sm_services.facet.limit=50&q={!boost+b%3Dboost_document}++{!payload_score+f%3Dboost_term+v%3D"club"+func%3Dmax}+(tm_X3b_en_rendered_item:(%2B"club")^2+tm_X3b_und_rendered_item:(%2B"club")^2+tm_X3b_zxx_rendered_item:(%2B"club")^2)&f.sm_neighborhoods.facet.limit=50&f.sm_cost_subsidies.facet.limit=50&facet.limit=10&f.ss_types.facet.limit=50&omitHeader=true&facet.mincount=1&facet=true&facet.sort=count&f.ss_virtual.facet.limit=50} hits=3 status=0 QTime=3

2021-08-28 06:20:18.542 INFO (qtp443721024-86) [ x:drupal] o.a.s.c.S.Request [drupal] webapp=/solr path=/select params={f.ss_virtual.facet.missing=false&bf=recip(abs(ms(NOW,ds_changed)),3.16e-11,.08,.05)&TZ=America/New_York&fl=,score&facet.missing=false&fq={!tag%3Dnonobsolete}(dm_dates_end:{“2021-08-28T06:20:18Z”+TO+}+(:+-dm_dates_end:[+TO+]))&fq=bs_status:“true”&fq={!tag%3Dfacet:services}sm_services:“Language+Instruction”&fq=%2Bindex_id:main&fq=ss_search_api_language:(“en”+“und”+“zxx”)&f.sm_ages.facet.missing=false&f.sm_services.facet.missing=false&f.ss_types.facet.missing=false&f.sm_activities.facet.missing=false&f.sm_neighborhoods.facet.missing=false&wt=json&facet.field={!key%3Dss_types+ex%3Dfacet:types}ss_types&facet.field={!key%3Dsm_neighborhoods+ex%3Dfacet:neighborhoods}sm_neighborhoods&facet.field={!key%3Dss_virtual+ex%3Dfacet:virtual}ss_virtual&facet.field={!key%3Dsm_cost_subsidies+ex%3Dfacet:cost_subsidies}sm_cost_subsidies&facet.field={!key%3Dsm_activities+ex%3Dfacet:activities}sm_activities&facet.field={!key%3Dsm_services+ex%3Dfacet:services}sm_services&facet.field={!key%3Dsm_ages+ex%3Dfacet:ages}sm_ages&json.nl=flat&f.sm_ages.facet.limit=50&f.sm_activities.facet.limit=50&start=0&f.sm_cost_subsidies.facet.missing=false&sort=score+desc&rows=25&f.sm_services.facet.limit=50&q={!boost+b%3Dboost_document}++{!payload_score+f%3Dboost_term+v%3D"club"+func%3Dmax}+(tm_X3b_en_rendered_item:(%2B"club")^2+tm_X3b_und_rendered_item:(%2B"club")^2+tm_X3b_zxx_rendered_item:(%2B"club")^2)&f.sm_neighborhoods.facet.limit=50&f.sm_cost_subsidies.facet.limit=50&facet.limit=10&f.ss_types.facet.limit=50&omitHeader=true&facet.mincount=1&facet=true&facet.sort=count&f.ss_virtual.facet.limit=50} hits=3 status=0 QTime=4

2021-08-28 06:28:58.884 INFO (qtp443721024-72) [ x:drupal] o.a.s.c.S.Request [drupal] webapp=/solr path=/select params={f.ss_virtual.facet.missing=false&bf=recip(abs(ms(NOW,ds_changed)),3.16e-11,.08,.05)&TZ=America/New_York&fl=,score&facet.missing=false&fq={!tag%3Dnonobsolete}(dm_dates_end:{“2021-08-28T06:28:58Z”+TO+}+(:+-dm_dates_end:[+TO+]))&fq=bs_status:“true”&fq={!tag%3Dfacet:services}sm_services:“Language+Instruction”&fq=%2Bindex_id:main&fq=ss_search_api_language:(“en”+“und”+“zxx”)&f.sm_ages.facet.missing=false&f.sm_services.facet.missing=false&f.ss_types.facet.missing=false&f.sm_activities.facet.missing=false&f.sm_neighborhoods.facet.missing=false&wt=json&facet.field={!key%3Dss_types+ex%3Dfacet:types}ss_types&facet.field={!key%3Dsm_neighborhoods+ex%3Dfacet:neighborhoods}sm_neighborhoods&facet.field={!key%3Dss_virtual+ex%3Dfacet:virtual}ss_virtual&facet.field={!key%3Dsm_cost_subsidies+ex%3Dfacet:cost_subsidies}sm_cost_subsidies&facet.field={!key%3Dsm_activities+ex%3Dfacet:activities}sm_activities&facet.field={!key%3Dsm_services+ex%3Dfacet:services}sm_services&facet.field={!key%3Dsm_ages+ex%3Dfacet:ages}sm_ages&json.nl=flat&f.sm_ages.facet.limit=50&f.sm_activities.facet.limit=50&start=0&f.sm_cost_subsidies.facet.missing=false&sort=score+desc&rows=25&f.sm_services.facet.limit=50&q={!boost+b%3Dboost_document}++{!payload_score+f%3Dboost_term+v%3D"club"+func%3Dmax}+(tm_X3b_en_rendered_item:(%2B"club")^2+tm_X3b_und_rendered_item:(%2B"club")^2+tm_X3b_zxx_rendered_item:(%2B"club")^2)&f.sm_neighborhoods.facet.limit=50&f.sm_cost_subsidies.facet.limit=50&facet.limit=10&f.ss_types.facet.limit=50&omitHeader=true&facet.mincount=1&facet=true&facet.sort=count&f.ss_virtual.facet.limit=50} hits=3 status=0 QTime=2

OK we’ve finally added it but it’s not doing anything:

2021-08-28 20:22:26.571 INFO (qtp443721024-81) [ x:drupal] o.a.s.c.S.Request [drupal] webapp=/solr path=/select params={f.ss_virtual.facet.missing=false&bf=recip(abs(ms(NOW,ds_changed)),3.16e-11,.08,.05)&TZ=America/New_York&fl=*,score&facet.missing=false&fq={!tag%3Dnonobsolete}(dm_dates_end:{"2021-08-28T20:22:26Z"+TO+*}+(*:*+-dm_dates_end:[*+TO+*]))&fq=bs_status:"true"&fq={!tag%3Dfacet:services}sm_services:"Language+Instruction"&fq=%2Bindex_id:main&fq=ss_search_api_language:("en"+"und"+"zxx")&f.sm_ages.facet.missing=false&f.sm_services.facet.missing=false&f.ss_types.facet.missing=false&f.sm_activities.facet.missing=false&f.sm_neighborhoods.facet.missing=false&wt=json&facet.field={!key%3Dss_types+ex%3Dfacet:types}ss_types&facet.field={!key%3Dsm_neighborhoods+ex%3Dfacet:neighborhoods}sm_neighborhoods&facet.field={!key%3Dss_virtual+ex%3Dfacet:virtual}ss_virtual&facet.field={!key%3Dsm_cost_subsidies+ex%3Dfacet:cost_subsidies}sm_cost_subsidies&facet.field={!key%3Dsm_activities+ex%3Dfacet:activities}sm_activities&facet.field={!key%3Dsm_services+ex%3Dfacet:services}sm_services&facet.field={!key%3Dsm_ages+ex%3Dfacet:ages}sm_ages&json.nl=flat&f.sm_ages.facet.limit=50&f.sm_activities.facet.limit=50&start=0&f.sm_cost_subsidies.facet.missing=false&sort=score+desc&rows=25&f.sm_services.facet.limit=50&q={!boost+b%3Dboost_document}++*:*+(sm_areas_of_focus:Language+Instruction)^%3D20&f.sm_neighborhoods.facet.limit=50&f.sm_cost_subsidies.facet.limit=50&facet.limit=10&f.ss_types.facet.limit=50&omitHeader=true&facet.mincount=1&facet=true&facet.sort=count&f.ss_virtual.facet.limit=50} hits=18 status=0 QTime=2

Example of a working query:

2021-08-29 14:13:57.271 INFO (qtp443721024-161) [ x:drupal] o.a.s.c.S.Request [drupal] webapp=/solr path=/select params={f.ss_virtual.facet.missing=false&bf=recip(abs(ms(NOW,ds_changed)),3.16e-11,.08,.05)&TZ=America/New_York&fl=*,score&facet.missing=false&fq={!tag%3Dnonobsolete}(dm_dates_end:{"2021-08-29T14:13:57Z"+TO+*}+(*:*+-dm_dates_end:[*+TO+*]))&fq=bs_status:"true"&fq={!tag%3Dfacet:services}sm_services:"Language+Instruction"&fq=%2Bindex_id:main&fq=ss_search_api_language:("en"+"und"+"zxx")&f.sm_ages.facet.missing=false&f.sm_services.facet.missing=false&f.ss_types.facet.missing=false&f.sm_activities.facet.missing=false&f.sm_neighborhoods.facet.missing=false&wt=json&facet.field={!key%3Dss_types+ex%3Dfacet:types}ss_types&facet.field={!key%3Dsm_neighborhoods+ex%3Dfacet:neighborhoods}sm_neighborhoods&facet.field={!key%3Dss_virtual+ex%3Dfacet:virtual}ss_virtual&facet.field={!key%3Dsm_cost_subsidies+ex%3Dfacet:cost_subsidies}sm_cost_subsidies&facet.field={!key%3Dsm_activities+ex%3Dfacet:activities}sm_activities&facet.field={!key%3Dsm_services+ex%3Dfacet:services}sm_services&facet.field={!key%3Dsm_ages+ex%3Dfacet:ages}sm_ages&json.nl=flat&f.sm_ages.facet.limit=50&f.sm_activities.facet.limit=50&start=0&f.sm_cost_subsidies.facet.missing=false&sort=score+desc&rows=25&f.sm_services.facet.limit=50&q={!boost+b%3Dboost_document}++{!payload_score+f%3Dboost_term+v%3D"Tutoring"+func%3Dmax}+(tm_X3b_en_rendered_item:(%2B"Tutoring")^2+tm_X3b_und_rendered_item:(%2B"Tutoring")^2+tm_X3b_zxx_rendered_item:(%2B"Tutoring")^2)+(sm_areas_of_focus:"Language+Instruction")^%3D30&f.sm_neighborhoods.facet.limit=50&f.sm_cost_subsidies.facet.limit=50&facet.limit=10&f.ss_types.facet.limit=50&omitHeader=true&facet.mincount=1&facet=true&facet.sort=count&f.ss_virtual.facet.limit=50} hits=6 status=0 QTime=4