SlideShare una empresa de Scribd logo
1 de 24
Descargar para leer sin conexión
Apache Solr: Beyond the
Search Page.
Rupert Jabelman
drupal.org/IRC: rupertj
Twitter: @rupertjabelman
Who are you again?

I work for Aroq - an online publisher.
We provide daily information in 4 industries: Auto,
Food, Drink, Clothing.
Auto is where I spend most of my time, working on
QUBE: a site for research and intelligence, rather than
news. QUBE uses Solr extensively, with ~ 65000
documents in its index.
What’s this about then?
How to use Solr for things that aren’t just the bog
standard search page:
1. Content admin page
2. Data visualisation
You can use these techniques to enhance normal
search pages too.
A (mostly) bog standard search page.

Text
An admin-focused search

Text
Data visualisation

Text
The Lie.
Differentiating your search pages.
Specialised image search

Text
Text

So what is Solr anyway?
Solr is a web service
And a request looks like this:
start=0&rows=20&&spellcheck=true&q=&fl=id%2Centity_id%2Centity_type%2Cbundle%2Cbundle_name%2Clabel%2Css_language
%2Cis_comment_count%2Cds_created%2Cds_changed%2Cscore%2Cpath%2Curl%2Cis_uid%2Ctos_name%2Cteaser%2Czm_parent_entity
%2Css_filemime%2Css_file_entity_title%2Css_file_entity_url%2Csm_vid_Segment%2Cim_segment%2Cds_production_dates
%2Cds_production_dates_end%2Css_platform_reference%2Css_platform_name%2Css_group_reference%2Css_group_name
%2Css_make_reference%2Css_make_name%2Csm_model_name_reference%2Csm_model_name_name%2Csm_parent_model_reference
%2Csm_parent_model_name%2Css_codename%2Csm_plant_reference%2Csm_plant_name%2Csm_vid_Production_status
%2Cds_next_product_action_date%2Cim_next_product_action%2Csm_vid_Product_action&mm=1&mm=100%25&pf=content
%5E2.0&ps=15&hl=true&hl.fl=content&hl.snippets=3&hl.mergeContigious=true&f.content.hl.alternateField=teaser&f.content.hl.maxAlternateFiel
dLength=256&qf=content%5E40&qf=label%5E5.0&qf=tags_h2_h3%5E3.0&qf=tags_h4_h5_h6%5E2.0&qf=tags_inline
%5E1.0&qf=taxonomy_names%5E2.0&qf=tos_name%5E3.0&qf=ts_comments
%5E20&facet=true&facet.sort=count&facet.mincount=1&facet.field=im_segment&facet.field=im_country&facet.field=im_production_status&facet.
field=sm_plant_reference&facet.field=sm_group_reference&facet.field=%7B%21ex%3Dsm_make_reference
%7Dsm_make_reference&facet.field=sm_model_name_reference&facet.field=ss_platform_reference&facet.field=is_eop_year&facet.field=is_so
p_year&facet.field=sm_revision_name_formatted&facet.field=is_owner&facet.field=im_field_priority&facet.field=im_field_company_reference&fa
cet.field=im_field_article_type&facet.field=is_uid&facet.field=im_field_intelligence_sector&facet.field=im_field_theme&facet.field=bundle&f.im_se
gment.facet.limit=-1&f.im_segment.facet.mincount=1&f.im_country.facet.limit=-1&f.im_country.facet.mincount=1&f.im_production_status.facet.lim
it=50&f.im_production_status.facet.mincount=1&f.sm_plant_reference.facet.limit=100&f.sm_plant_reference.facet.mincount=1&f.sm_group_refer
ence.facet.limit=50&f.sm_group_reference.facet.mincount=1&f.sm_make_reference.facet.limit=50&f.sm_make_reference.facet.mincount=1&f.s
m_model_name_reference.facet.limit=50&f.sm_model_name_reference.facet.mincount=1&f.ss_platform_reference.facet.limit=100&f.ss_platform
_reference.facet.mincount=1&f.is_eop_year.facet.limit=50&f.is_eop_year.facet.mincount=1&f.is_sop_year.facet.limit=50&f.is_sop_year.facet.min
count=1&f.sm_revision_name_formatted.facet.limit=50&f.sm_revision_name_formatted.facet.mincount=1&f.is_owner.facet.limit=50&f.is_owner.f
acet.mincount=1&f.im_field_priority.facet.limit=50&f.im_field_priority.facet.mincount=1&f.im_field_company_reference.facet.limit=50&f.im_field_c
ompany_reference.facet.mincount=1&f.im_field_article_type.facet.limit=50&f.im_field_article_type.facet.mincount=1&facet.date=ds_created&fac
et.date=ds_changed&f.ds_created.facet.date.start=1997-01-01T00%3A00%3A00Z
%2FYEAR&f.ds_created.facet.date.end=2014-01-01T00%3A00%3A00Z%2B1YEAR%2FYEAR&f.ds_created.facet.date.gap=
%2B1YEAR&f.ds_created.facet.limit=50&f.is_uid.facet.limit=50&f.is_uid.facet.mincount=1&f.ds_changed.facet.date.start=2009-01-01T00%3A00
%3A00Z%2FYEAR&f.ds_changed.facet.date.end=2014-01-01T00%3A00%3A00Z%2B1YEAR%2FYEAR&f.ds_changed.facet.date.gap=
%2B1YEAR&f.ds_changed.facet.limit=50&f.im_field_intelligence_sector.facet.limit=50&f.im_field_intelligence_sector.facet.mincount=1&f.im_field
_theme.facet.limit=50&f.im_field_theme.facet.mincount=1&f.bundle.facet.limit=50&f.bundle.facet.mincount=1&sort=ds_changed%20desc&q.alt=
%28entity_type%3Aqube_entity%29%20%28bundle%3Aproduction_run%29%20%28im_production_status%3A1167%29&wt=json&json.nl=map!
Solr is a web service
And a (helpfully formatted) request looks like this:
q = Toyota!
fq = entity_type:qube_entity!
fq = bundle:production_run!
fq = ss_platform_reference:”qube_entity:3505"!
fl = id, entity_id, entity_type, bundle, bundle_name, label, ss_language, is_comment_count, ds_created, ds_changed, score, path,
url, is_uid, tos_name, teaser, zm_parent_entity, ss_filemime, ss_file_entity_title, ss_file_entity_url, sm_vid_Segment, im_segment,
ds_production_dates, ds_production_dates_end, ss_platform_reference, ss_platform_name, ss_group_reference, ss_group_name,
ss_make_reference, ss_make_name, sm_model_name_reference, sm_model_name_name, sm_parent_model_reference,
sm_parent_model_name, ss_codename, sm_plant_reference, sm_plant_name, sm_vid_Production_status,
ds_next_product_action_date, im_next_product_action, sm_vid_Product_action!
mm = 100%!
start = 0!
rows = 20!
spellcheck = true!
pf = content^2.0!
ps = 15!
hl = true!
hl.fl = content!
hl.snippets = 3!
hl.mergeContigious = true!
qf = content^40!
qf = label^5.0!
qf = tags_h2_h3^3.0!
qf = tags_h4_h5_h6^2.0!
qf = tags_inline^1.0!
qf = taxonomy_names^2.0!
qf = tos_name^3.0!
qf = ts_comments^20!
sort = ds_changed desc!
wt = json!
json.nl = map!
Dynamic Fields
So any field you’ve added through Field API can be shown in solr
without changing the schema, dynamic fields are used. These have
their properties defined by their prefix.
EG:
•

im_foo => integer, multi-valued. EG Taxonomy term IDs.

•

sm_bar => string, multi-valued. EG Taxonomy term names.

•

bs_grill => boolean, single. EG Checkbox fields.

Most fields are added for you, but you can always add your own. In
fact, you’ll probably have to.
You’ll need
to feed Solr
more data
Adding extra data.
hook_apachesolr_index_documents_alter(array &$documents,
$entity, $entity_type, $env_id) {
$document = reset($documents);
$document->setField('ss_foo', $entity->field_foo…);
}
Most field data is included for you already (with a few exceptions). Data you add
here can be anything you like though.
Checking your work: Solr admin.
Modifying queries.
Add extra fields to the results:

hook_apachesolr_query_alter($query) {
$query->addParam('fl', ‘sm_foo’);
}
Changing the query fields:

hook_apachesolr_query_alter($query) {
$query->replaceParam('qf', array(
‘label^2.0',
'content^1.0',
));
}
Modifying queries.
Changing the number of results to return:

hook_apachesolr_query_alter($query) {
// Solr doesn't have a value for “unlimited"
// so we'll pass in a Very Large Number.
$query->addParam('rows', 999999);
}
Changing the sort order (setting a default in this case):

hook_apachesolr_query_alter($query) {
if (!isset($_GET['solrsort']) && ($query->getParam('q') == '')) {
$query->setSolrSort('ds_changed', 'desc');
}
}
Adding sorts
Override SolrBaseQuery. apachesolr_query_class variable controls which is instantiated.
class MySolrBaseQuery extends SolrBaseQuery {
protected function defaultSorts() {
$sorts = parent::defaultSorts();
// Add in core changed property. Missing by default.
$sorts['ds_changed'] =
array('title' => t('Updated Date'), 'default' => 'desc');
}
}
apachesolr_sort module can be used to manage sorts:

•

Choose a default sort & order.


•

Enable / Disable the available sorts.
Bringing it all together.
Create a search page.
Apply the limits you need. Eg entity type, bundles, etc.
Add the data you need to solr documents.
Alter the query to add any additional fields you want to
display.
Place any facet blocks you want.
Theme it.
An admin-focused search

Text
Data visualisation

Text
Swopping out theme functions.
function hook_apachesolr_search_page_alter(&$build, $search_page) {
if ($search_page['page_id'] == 'pldb') {
// If a timeseries view was requested, switch the theme function to one we define that
draws timeseries.
if (qube_pldb_search_results_view() == 'timeseries') {
$env_id = 'solr';
if (apachesolr_has_searched($env_id)) {
$query = apachesolr_current_query($env_id);
if (qube_pldb_search_results_view_timeseries_allowed($query)) {
$build['search_results']['#theme'] = 'search_results_timeseries';
}
….
Fin.

Any questions?

Más contenido relacionado

Último

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 

Último (20)

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 

Destacado

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellSaba Software
 

Destacado (20)

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 

Apache Solr: beyond the search page, from Drupalcon London 2014

  • 1. Apache Solr: Beyond the Search Page. Rupert Jabelman drupal.org/IRC: rupertj Twitter: @rupertjabelman
  • 2. Who are you again? I work for Aroq - an online publisher. We provide daily information in 4 industries: Auto, Food, Drink, Clothing. Auto is where I spend most of my time, working on QUBE: a site for research and intelligence, rather than news. QUBE uses Solr extensively, with ~ 65000 documents in its index.
  • 3. What’s this about then? How to use Solr for things that aren’t just the bog standard search page: 1. Content admin page 2. Data visualisation You can use these techniques to enhance normal search pages too.
  • 4. A (mostly) bog standard search page. Text
  • 10. Text So what is Solr anyway?
  • 11. Solr is a web service And a request looks like this: start=0&rows=20&&spellcheck=true&q=&fl=id%2Centity_id%2Centity_type%2Cbundle%2Cbundle_name%2Clabel%2Css_language %2Cis_comment_count%2Cds_created%2Cds_changed%2Cscore%2Cpath%2Curl%2Cis_uid%2Ctos_name%2Cteaser%2Czm_parent_entity %2Css_filemime%2Css_file_entity_title%2Css_file_entity_url%2Csm_vid_Segment%2Cim_segment%2Cds_production_dates %2Cds_production_dates_end%2Css_platform_reference%2Css_platform_name%2Css_group_reference%2Css_group_name %2Css_make_reference%2Css_make_name%2Csm_model_name_reference%2Csm_model_name_name%2Csm_parent_model_reference %2Csm_parent_model_name%2Css_codename%2Csm_plant_reference%2Csm_plant_name%2Csm_vid_Production_status %2Cds_next_product_action_date%2Cim_next_product_action%2Csm_vid_Product_action&mm=1&mm=100%25&pf=content %5E2.0&ps=15&hl=true&hl.fl=content&hl.snippets=3&hl.mergeContigious=true&f.content.hl.alternateField=teaser&f.content.hl.maxAlternateFiel dLength=256&qf=content%5E40&qf=label%5E5.0&qf=tags_h2_h3%5E3.0&qf=tags_h4_h5_h6%5E2.0&qf=tags_inline %5E1.0&qf=taxonomy_names%5E2.0&qf=tos_name%5E3.0&qf=ts_comments %5E20&facet=true&facet.sort=count&facet.mincount=1&facet.field=im_segment&facet.field=im_country&facet.field=im_production_status&facet. field=sm_plant_reference&facet.field=sm_group_reference&facet.field=%7B%21ex%3Dsm_make_reference %7Dsm_make_reference&facet.field=sm_model_name_reference&facet.field=ss_platform_reference&facet.field=is_eop_year&facet.field=is_so p_year&facet.field=sm_revision_name_formatted&facet.field=is_owner&facet.field=im_field_priority&facet.field=im_field_company_reference&fa cet.field=im_field_article_type&facet.field=is_uid&facet.field=im_field_intelligence_sector&facet.field=im_field_theme&facet.field=bundle&f.im_se gment.facet.limit=-1&f.im_segment.facet.mincount=1&f.im_country.facet.limit=-1&f.im_country.facet.mincount=1&f.im_production_status.facet.lim it=50&f.im_production_status.facet.mincount=1&f.sm_plant_reference.facet.limit=100&f.sm_plant_reference.facet.mincount=1&f.sm_group_refer ence.facet.limit=50&f.sm_group_reference.facet.mincount=1&f.sm_make_reference.facet.limit=50&f.sm_make_reference.facet.mincount=1&f.s m_model_name_reference.facet.limit=50&f.sm_model_name_reference.facet.mincount=1&f.ss_platform_reference.facet.limit=100&f.ss_platform _reference.facet.mincount=1&f.is_eop_year.facet.limit=50&f.is_eop_year.facet.mincount=1&f.is_sop_year.facet.limit=50&f.is_sop_year.facet.min count=1&f.sm_revision_name_formatted.facet.limit=50&f.sm_revision_name_formatted.facet.mincount=1&f.is_owner.facet.limit=50&f.is_owner.f acet.mincount=1&f.im_field_priority.facet.limit=50&f.im_field_priority.facet.mincount=1&f.im_field_company_reference.facet.limit=50&f.im_field_c ompany_reference.facet.mincount=1&f.im_field_article_type.facet.limit=50&f.im_field_article_type.facet.mincount=1&facet.date=ds_created&fac et.date=ds_changed&f.ds_created.facet.date.start=1997-01-01T00%3A00%3A00Z %2FYEAR&f.ds_created.facet.date.end=2014-01-01T00%3A00%3A00Z%2B1YEAR%2FYEAR&f.ds_created.facet.date.gap= %2B1YEAR&f.ds_created.facet.limit=50&f.is_uid.facet.limit=50&f.is_uid.facet.mincount=1&f.ds_changed.facet.date.start=2009-01-01T00%3A00 %3A00Z%2FYEAR&f.ds_changed.facet.date.end=2014-01-01T00%3A00%3A00Z%2B1YEAR%2FYEAR&f.ds_changed.facet.date.gap= %2B1YEAR&f.ds_changed.facet.limit=50&f.im_field_intelligence_sector.facet.limit=50&f.im_field_intelligence_sector.facet.mincount=1&f.im_field _theme.facet.limit=50&f.im_field_theme.facet.mincount=1&f.bundle.facet.limit=50&f.bundle.facet.mincount=1&sort=ds_changed%20desc&q.alt= %28entity_type%3Aqube_entity%29%20%28bundle%3Aproduction_run%29%20%28im_production_status%3A1167%29&wt=json&json.nl=map!
  • 12. Solr is a web service And a (helpfully formatted) request looks like this: q = Toyota! fq = entity_type:qube_entity! fq = bundle:production_run! fq = ss_platform_reference:”qube_entity:3505"! fl = id, entity_id, entity_type, bundle, bundle_name, label, ss_language, is_comment_count, ds_created, ds_changed, score, path, url, is_uid, tos_name, teaser, zm_parent_entity, ss_filemime, ss_file_entity_title, ss_file_entity_url, sm_vid_Segment, im_segment, ds_production_dates, ds_production_dates_end, ss_platform_reference, ss_platform_name, ss_group_reference, ss_group_name, ss_make_reference, ss_make_name, sm_model_name_reference, sm_model_name_name, sm_parent_model_reference, sm_parent_model_name, ss_codename, sm_plant_reference, sm_plant_name, sm_vid_Production_status, ds_next_product_action_date, im_next_product_action, sm_vid_Product_action! mm = 100%! start = 0! rows = 20! spellcheck = true! pf = content^2.0! ps = 15! hl = true! hl.fl = content! hl.snippets = 3! hl.mergeContigious = true! qf = content^40! qf = label^5.0! qf = tags_h2_h3^3.0! qf = tags_h4_h5_h6^2.0! qf = tags_inline^1.0! qf = taxonomy_names^2.0! qf = tos_name^3.0! qf = ts_comments^20! sort = ds_changed desc! wt = json! json.nl = map!
  • 13. Dynamic Fields So any field you’ve added through Field API can be shown in solr without changing the schema, dynamic fields are used. These have their properties defined by their prefix. EG: • im_foo => integer, multi-valued. EG Taxonomy term IDs. • sm_bar => string, multi-valued. EG Taxonomy term names. • bs_grill => boolean, single. EG Checkbox fields. Most fields are added for you, but you can always add your own. In fact, you’ll probably have to.
  • 14. You’ll need to feed Solr more data
  • 15. Adding extra data. hook_apachesolr_index_documents_alter(array &$documents, $entity, $entity_type, $env_id) { $document = reset($documents); $document->setField('ss_foo', $entity->field_foo…); } Most field data is included for you already (with a few exceptions). Data you add here can be anything you like though.
  • 16. Checking your work: Solr admin.
  • 17. Modifying queries. Add extra fields to the results: hook_apachesolr_query_alter($query) { $query->addParam('fl', ‘sm_foo’); } Changing the query fields: hook_apachesolr_query_alter($query) { $query->replaceParam('qf', array( ‘label^2.0', 'content^1.0', )); }
  • 18. Modifying queries. Changing the number of results to return: hook_apachesolr_query_alter($query) { // Solr doesn't have a value for “unlimited" // so we'll pass in a Very Large Number. $query->addParam('rows', 999999); } Changing the sort order (setting a default in this case): hook_apachesolr_query_alter($query) { if (!isset($_GET['solrsort']) && ($query->getParam('q') == '')) { $query->setSolrSort('ds_changed', 'desc'); } }
  • 19. Adding sorts Override SolrBaseQuery. apachesolr_query_class variable controls which is instantiated. class MySolrBaseQuery extends SolrBaseQuery { protected function defaultSorts() { $sorts = parent::defaultSorts(); // Add in core changed property. Missing by default. $sorts['ds_changed'] = array('title' => t('Updated Date'), 'default' => 'desc'); } } apachesolr_sort module can be used to manage sorts: • Choose a default sort & order. • Enable / Disable the available sorts.
  • 20. Bringing it all together. Create a search page. Apply the limits you need. Eg entity type, bundles, etc. Add the data you need to solr documents. Alter the query to add any additional fields you want to display. Place any facet blocks you want. Theme it.
  • 23. Swopping out theme functions. function hook_apachesolr_search_page_alter(&$build, $search_page) { if ($search_page['page_id'] == 'pldb') { // If a timeseries view was requested, switch the theme function to one we define that draws timeseries. if (qube_pldb_search_results_view() == 'timeseries') { $env_id = 'solr'; if (apachesolr_has_searched($env_id)) { $query = apachesolr_current_query($env_id); if (qube_pldb_search_results_view_timeseries_allowed($query)) { $build['search_results']['#theme'] = 'search_results_timeseries'; } ….