SlideShare a Scribd company logo
+ ajax-solr
Solr (pronounced "solar") is an open source
enterprise search platform from the Apache
Lucene project. Its major features include full-
text search, hit highlighting, faceted search,
dynamic clustering, database integration, and
rich document (e.g., Word, PDF) handling. [...]
Solr is the most popular enterprise search
engine. Solr 4 adds NoSQL features.
What is Solr (1)
Solr is written in Java and runs as a standalone
full-text search server within a servlet container
such as Apache Tomcat or Jetty.
Solr uses the Lucene Java search library at its
core for full-text indexing and search, and has
REST-like HTTP/XML and JSON APIs that
make it usable from most popular
programming languages.
(source: wikipedia)
What is Solr (2)
Installing Solr (speedrun)
# tar zxvf solr-4.10.0.tgz
# mv solr-4.10.0 /opt/
Solr comes already configured, for fine tuning
the Solr fields, modify the file
/opt/solr-
4.10.0/example/solr/collection1/conf/schema.xml
Configuring Solr
Running Solr - Jetty
Solr includes a configured jetty installation, to
run it:
# cd /opt/solr-4.10.0/example/
# java -jar start.jar
Create a Tomcat context file:
/var/lib/tomcat6/conf/Catalina/localhost/mysolr.xml
(better yet, create it somewhere else and link it
there)
Running Solr - Tomcat (1)
Context file content:
<?xml version="1.0" encoding="utf-8"?>
<Context docBase="/opt/solr-
4.10.0/example/webapps/solr.war" debug="0"
crossContext="true">
<Environment name="solr/home"
type="java.lang.String" value="/opt/solr-
4.10.0/example/solr" override="true"/>
</Context>
Running Solr - Tomcat (2)
Tomcat: find the app “mysolr” in
the manager webapp
Jetty: http://localhost:8983/solr/
Solr Admin interface
Untar the solr-4.10.0.tgz files multiple times,
and rename the directories.
# tar zxvf solr-4.10.0.tgz
# cp -a solr-4.10.0 /opt/mysolr1
# cp -a solr-4.10.0 /opt/mysolr2
Multiple Solr instances (1)
Create multiple context files with different
names, each of them must point to a different
solr installation.
/var/lib/tomcat6/conf/Catalina/localhost/solrApp1.xml
/var/lib/tomcat6/conf/Catalina/localhost/solrApp2.xml
Multiple Solr instances (2)
Change the context files content, to point to the
right solr installation. File solrApp1.xml:
<?xml version="1.0" encoding="utf-8"?>
<Context
docBase="/opt/mysolr1/example/webapps/solr.war"
debug="0" crossContext="true">
<Environment name="solr/home"
type="java.lang.String"
value="/opt/mysolr1/example/solr" override="true"/>
</Context>
Multiple Solr instances (3)
Change the context files content, to point to the
right solr installation. File solrApp2.xml:
<?xml version="1.0" encoding="utf-8"?>
<Context
docBase="/opt/mysolr2/example/webapps/solr.war"
debug="0" crossContext="true">
<Environment name="solr/home"
type="java.lang.String"
value="/opt/mysolr2/example/solr" override="true"/>
</Context>
Multiple Solr instances (4)
The Solr schema must have an unique field,
identified in the schema.xml file by something
like:
<uniqueKey>id</uniqueKey>
where id is the field defined by:
<field name="id" type="string" indexed="true"
stored="true" required="true" multiValued="false" />
Solr Schema (1)
For most of the other fields of the indexed
resources, you will use the Solr dynamic fields
defined in the scheme like the following ones:
<dynamicField name="*_i" type="int"
indexed="true" stored="true"/> <dynamicField
name="*_is" type="int" indexed="true" stored="true"
multiValued="true"/>
Solr Schema (2)
Solr field types are defined in the schema too:
<fieldType name="int" class="solr.TrieIntField"
precisionStep="0" positionIncrementGap="0"/>
<fieldType name="float" class="solr.TrieFloatField"
precisionStep="0" positionIncrementGap="0"/>
Solr Schema (3)
Text types can have some magic stuff:
<!-- A text field that only splits on whitespace for exact
matching of words -->
<fieldType name="text_ws" class="solr.TextField"
positionIncrementGap="100">
<analyzer>
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
</analyzer>
</fieldType>
Solr Schema (4)
<fieldType name="text_en" class="solr.TextField"
positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter [...]/> <!-- +other filters -->
</analyzer>
<analyzer type="query">
<tokenizer [...]/> <filter [...]/> <!-- +other filters -->
</analyzer>
</fieldType>
Solr Schema (5)
Analyzers are components that pre-process
input text at index time and/or at search time.
It's important to use the same or similar
analyzers that process text in a compatible
manner at index and query time. For example,
if an indexing analyzer lowercases words, then
the query analyzer should do the same to
enable finding the indexed words.
(from https://wiki.apache.org/solr/)
Solr Schema (6)
Tokenizer examples:
● <tokenizer class="solr.WhitespaceTokenizerFactory"/>
● <tokenizer class="solr.StandardTokenizerFactory"/>
● <tokenizer class="solr.LetterTokenizerFactory"/>
● <tokenizer class="solr.LowerCaseTokenizerFactory"/>
Solr Schema (7)
Filter examples:
● <filter class="solr.LowerCaseFilterFactory"/>
● <filter
class="solr.RemoveDuplicatesTokenFilterFactory"/>
● <filter class="solr.StopFilterFactory"
ignoreCase="true" words="stopwords.txt" />
● <filter
class="solr.GermanNormalizationFilterFactory"/>
● <filter class="solr.GermanLightStemFilterFactory"/>
Solr Schema (8)
Although the schema is already set up, you
should really go through it and get rid of all the
unnecessary stuff!
Get rid of all the fields and types you don’t
need, maintainability will be enhanced, and
everything will look much clearer!
Solr Schema (9)
Solr can be indexed in many ways, depending
on your application technology.
● In PHP: you can use Solarium, a Solr
client library
● In Java: you can use Solrj
● Using Data Import Request Handler
Indexing Solr (1)
Synchronous indexing:
PHP or Java you listen to DataBase insertion,
deletion and update, and call the related Solr
APIs (by using the libraries, possibly)
Indexing Solr (2)
Synchronous indexing, pitfalls:
What if Solr is down? - find a way to be sure the
sync is done!
Indexing Solr (3)
AJAX Solr loosely follows the Model-view-
controller pattern. The ParameterStore is
the model, storing the Solr parameters and,
thus, the state of the application. The
Manager is the controller; it talks to the
ParameterStore, sends requests to Solr, and
delegates the response to the widgets for
rendering. The widgets are the views, each
rendering a part of the interface.
Ajax-Solr (1)
AJAX Solr it’s a javascript application.
It offers an autocomplete feature searching in
multiple fields (reported in the result list),
faceted search based tagcloud, result display
Ajax-Solr (2)
Download zip from
https://github.com/evolvingweb/ajax-solr/
unzip:
# unzip ajax-solr-master.zip
Ajax-Solr - Deployment (1)
Use /examples/reuters-requirejs/ as a starting
point for your application.
In /examples/reuters-requirejs/js/reuters.js
set Solr address
solrUrl: 'http://localhost:8983/solr/',
Ajax-Solr - Deployment (2)
In the same reuters.js set the fields to be used.
Just before:
Manager.addWidget(new AjaxSolr.TagcloudWidget
Set the fields var with the fields you want to use
in the tag clouds, e.g.
var fields = [‘notebook_label_s’,’user_s’];
Ajax-Solr - Deployment (3)
Now we set parameters for the facet (used in
the tag clouds):
var params = {
facet: true,
'facet.field': [ 'notebook_label_s', 'user_s'],
'facet.limit': 20,
'facet.mincount': 1,
'f.notebook_label_s.facet.limit': 50,
'f.user_s.facet.limit': 50,
Ajax-Solr - Deployment (4)
We may add other parameters to the facet
query here
'fq': 'basket_id_s:' +basket_id
or
'fq': 'my_field_i:8'
Ajax-Solr - Deployment (5)
In the
Manager.addWidget(new AjaxSolr.AutocompleteWidget({
set the fields to be used for the autocomplete :
var fields = [‘notebook_label_s’,’predicate_label_s’];
Ajax-Solr - Deployment (6)
In the index.html example page everything is
already set up. You’ll just need to customize the
tagclouds, by adding/modifying the tagcloud
tags, like
<h2>Notebooks</h2>
<div class="tagcloud" id="notebook_label_s"> </div>
<h2>Users</h2>
<div class="tagcloud" id="user_s"> </div>
Ajax-Solr - Deployment (7)
One last thing you may want to do, is customize
the results output, in the /examples/reuters-
requirejs/widgets/ResultWidget.js file, modify
the content of:
template: function (doc) {
[...]
}
Ajax-Solr - Deployment (8)
Solr: http://lucene.apache.org/solr/
Ajax-Solr:
https://github.com/evolvingweb/ajax-solr/
Solarium: http://www.solarium-project.org/
Solr wiki: http://wiki.apache.org/solr/
Resources

More Related Content

What's hot (20)

PDF
Solr Troubleshooting - TreeMap approach
Alexandre Rafalovitch
 
PDF
Solr Masterclass Bangkok, June 2014
Alexandre Rafalovitch
 
PDF
Rapid Prototyping with Solr
Erik Hatcher
 
PPT
Enterprise Search Solution: Apache SOLR. What's available and why it's so cool
Ecommerce Solution Provider SysIQ
 
PPTX
JSON in Solr: from top to bottom
Alexandre Rafalovitch
 
PDF
Schemaless Solr and the Solr Schema REST API
lucenerevolution
 
PDF
Lucene for Solr Developers
Erik Hatcher
 
ODP
Searching for AI - Leveraging Solr for classic Artificial Intelligence tasks
Alexandre Rafalovitch
 
PPTX
Apache Solr Workshop
JSGB
 
PDF
Apache Solr! Enterprise Search Solutions at your Fingertips!
Murshed Ahmmad Khan
 
PPTX
Rapid Solr Schema Development (Phone directory)
Alexandre Rafalovitch
 
PDF
From content to search: speed-dating Apache Solr (ApacheCON 2018)
Alexandre Rafalovitch
 
PDF
Introduction to Solr
Erik Hatcher
 
PPTX
Apache Solr
Minh Tran
 
PPT
Solr Presentation
Gaurav Verma
 
PDF
New-Age Search through Apache Solr
Edureka!
 
PDF
Solr Recipes Workshop
Erik Hatcher
 
PPTX
Solr 6 Feature Preview
Yonik Seeley
 
PDF
Building your own search engine with Apache Solr
Biogeeks
 
PDF
Get the most out of Solr search with PHP
Paul Borgermans
 
Solr Troubleshooting - TreeMap approach
Alexandre Rafalovitch
 
Solr Masterclass Bangkok, June 2014
Alexandre Rafalovitch
 
Rapid Prototyping with Solr
Erik Hatcher
 
Enterprise Search Solution: Apache SOLR. What's available and why it's so cool
Ecommerce Solution Provider SysIQ
 
JSON in Solr: from top to bottom
Alexandre Rafalovitch
 
Schemaless Solr and the Solr Schema REST API
lucenerevolution
 
Lucene for Solr Developers
Erik Hatcher
 
Searching for AI - Leveraging Solr for classic Artificial Intelligence tasks
Alexandre Rafalovitch
 
Apache Solr Workshop
JSGB
 
Apache Solr! Enterprise Search Solutions at your Fingertips!
Murshed Ahmmad Khan
 
Rapid Solr Schema Development (Phone directory)
Alexandre Rafalovitch
 
From content to search: speed-dating Apache Solr (ApacheCON 2018)
Alexandre Rafalovitch
 
Introduction to Solr
Erik Hatcher
 
Apache Solr
Minh Tran
 
Solr Presentation
Gaurav Verma
 
New-Age Search through Apache Solr
Edureka!
 
Solr Recipes Workshop
Erik Hatcher
 
Solr 6 Feature Preview
Yonik Seeley
 
Building your own search engine with Apache Solr
Biogeeks
 
Get the most out of Solr search with PHP
Paul Borgermans
 

Similar to Apache Solr + ajax solr (20)

PDF
Apache solr liferay
Binesh Gummadi
 
PPTX
Solr introduction
Lap Tran
 
PPTX
Search Engine Building with Lucene and Solr (So Code Camp San Diego 2014)
Kai Chan
 
PDF
Apache Solr crash course
Tommaso Teofili
 
PDF
Basics of Solr and Solr Integration with AEM6
DEEPAK KHETAWAT
 
KEY
Apache Solr - Enterprise search platform
Tommaso Teofili
 
PPTX
20130310 solr tuorial
Chris Huang
 
KEY
Solr 101
Findwise
 
DOCX
Apache solr tech doc
Barot Sagar
 
PPTX
Apache Solr - search for everyone!
Jaran Flaath
 
PDF
Information Retrieval - Data Science Bootcamp
Kais Hassan, PhD
 
PDF
Introduction to Apache Solr
Christos Manios
 
PDF
Introduction to Solr
Erik Hatcher
 
PPTX
Assamese search engine using SOLR by Moinuddin Ahmed ( moin )
'Moinuddin Ahmed
 
PDF
Solr Powered Lucene
Erik Hatcher
 
PPTX
Apache Solr for begginers
Alexander Tokarev
 
ODP
Solr features
Marcos García
 
PPTX
IT talk SPb "Full text search for lazy guys"
DataArt
 
ODP
Introduction to Apache solr
Knoldus Inc.
 
PDF
Solr Architecture
Ramez Al-Fayez
 
Apache solr liferay
Binesh Gummadi
 
Solr introduction
Lap Tran
 
Search Engine Building with Lucene and Solr (So Code Camp San Diego 2014)
Kai Chan
 
Apache Solr crash course
Tommaso Teofili
 
Basics of Solr and Solr Integration with AEM6
DEEPAK KHETAWAT
 
Apache Solr - Enterprise search platform
Tommaso Teofili
 
20130310 solr tuorial
Chris Huang
 
Solr 101
Findwise
 
Apache solr tech doc
Barot Sagar
 
Apache Solr - search for everyone!
Jaran Flaath
 
Information Retrieval - Data Science Bootcamp
Kais Hassan, PhD
 
Introduction to Apache Solr
Christos Manios
 
Introduction to Solr
Erik Hatcher
 
Assamese search engine using SOLR by Moinuddin Ahmed ( moin )
'Moinuddin Ahmed
 
Solr Powered Lucene
Erik Hatcher
 
Apache Solr for begginers
Alexander Tokarev
 
Solr features
Marcos García
 
IT talk SPb "Full text search for lazy guys"
DataArt
 
Introduction to Apache solr
Knoldus Inc.
 
Solr Architecture
Ramez Al-Fayez
 
Ad

More from Net7 (20)

PDF
E-RIHS Heritage Hub
Net7
 
PDF
Net7 @ Master Big Data 2017
Net7
 
PPTX
Presentation of context: Web Annotations (& Pundit) during the StoM Project (...
Net7
 
PDF
iAnnotate 2016 - Demo Pundit web annotator
Net7
 
PDF
Pundit at Digital Humanities Austria 2015
Net7
 
PDF
La semantica per automatizzare una redazione web: l’esperienza di Innolabspl...
Net7
 
PDF
Pundit at DINI Jahrestagungen, 2015 "Linked Data – Vision und Wirklichkeit"
Net7
 
PDF
Muruca at DiXiT Convention 1: Technology, Software, Standards
Net7
 
PDF
Pundit workshop tutorial at DiXiT Convention 1: Technology, Software, Standards
Net7
 
PDF
Pundit at DiXiT Convention 1: Technology, Software, Standards
Net7
 
PDF
Trend Analysis sui Social Network - I risultati del progetto SenTaClAus
Net7
 
PDF
Word Embedding e word2vec: Introduzione ed Esperimenti Preliminari
Net7
 
PDF
Social Media Analysis... according to Net7
Net7
 
PDF
Io sono qui per voi - Giulio Andreini
Net7
 
PDF
C'è semantica in questo web
Net7
 
PDF
Rethinking the Role of SSH - Culture and Creativity
Net7
 
PDF
Pundit at 3rd DBpedia Community Meeting 2015
Net7
 
PDF
Lod portal and pundit @ Humanities Hack london2014
Net7
 
PDF
Looking at Words through Images - Presentation at CASVA, National Gallery of ...
Net7
 
PPTX
Looking at Words through Images - Presentation at CASVA, National Gallery of ...
Net7
 
E-RIHS Heritage Hub
Net7
 
Net7 @ Master Big Data 2017
Net7
 
Presentation of context: Web Annotations (& Pundit) during the StoM Project (...
Net7
 
iAnnotate 2016 - Demo Pundit web annotator
Net7
 
Pundit at Digital Humanities Austria 2015
Net7
 
La semantica per automatizzare una redazione web: l’esperienza di Innolabspl...
Net7
 
Pundit at DINI Jahrestagungen, 2015 "Linked Data – Vision und Wirklichkeit"
Net7
 
Muruca at DiXiT Convention 1: Technology, Software, Standards
Net7
 
Pundit workshop tutorial at DiXiT Convention 1: Technology, Software, Standards
Net7
 
Pundit at DiXiT Convention 1: Technology, Software, Standards
Net7
 
Trend Analysis sui Social Network - I risultati del progetto SenTaClAus
Net7
 
Word Embedding e word2vec: Introduzione ed Esperimenti Preliminari
Net7
 
Social Media Analysis... according to Net7
Net7
 
Io sono qui per voi - Giulio Andreini
Net7
 
C'è semantica in questo web
Net7
 
Rethinking the Role of SSH - Culture and Creativity
Net7
 
Pundit at 3rd DBpedia Community Meeting 2015
Net7
 
Lod portal and pundit @ Humanities Hack london2014
Net7
 
Looking at Words through Images - Presentation at CASVA, National Gallery of ...
Net7
 
Looking at Words through Images - Presentation at CASVA, National Gallery of ...
Net7
 
Ad

Recently uploaded (20)

PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Biography of Daniel Podor.pdf
Daniel Podor
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 

Apache Solr + ajax solr

  • 2. Solr (pronounced "solar") is an open source enterprise search platform from the Apache Lucene project. Its major features include full- text search, hit highlighting, faceted search, dynamic clustering, database integration, and rich document (e.g., Word, PDF) handling. [...] Solr is the most popular enterprise search engine. Solr 4 adds NoSQL features. What is Solr (1)
  • 3. Solr is written in Java and runs as a standalone full-text search server within a servlet container such as Apache Tomcat or Jetty. Solr uses the Lucene Java search library at its core for full-text indexing and search, and has REST-like HTTP/XML and JSON APIs that make it usable from most popular programming languages. (source: wikipedia) What is Solr (2)
  • 4. Installing Solr (speedrun) # tar zxvf solr-4.10.0.tgz # mv solr-4.10.0 /opt/
  • 5. Solr comes already configured, for fine tuning the Solr fields, modify the file /opt/solr- 4.10.0/example/solr/collection1/conf/schema.xml Configuring Solr
  • 6. Running Solr - Jetty Solr includes a configured jetty installation, to run it: # cd /opt/solr-4.10.0/example/ # java -jar start.jar
  • 7. Create a Tomcat context file: /var/lib/tomcat6/conf/Catalina/localhost/mysolr.xml (better yet, create it somewhere else and link it there) Running Solr - Tomcat (1)
  • 8. Context file content: <?xml version="1.0" encoding="utf-8"?> <Context docBase="/opt/solr- 4.10.0/example/webapps/solr.war" debug="0" crossContext="true"> <Environment name="solr/home" type="java.lang.String" value="/opt/solr- 4.10.0/example/solr" override="true"/> </Context> Running Solr - Tomcat (2)
  • 9. Tomcat: find the app “mysolr” in the manager webapp Jetty: http://localhost:8983/solr/ Solr Admin interface
  • 10. Untar the solr-4.10.0.tgz files multiple times, and rename the directories. # tar zxvf solr-4.10.0.tgz # cp -a solr-4.10.0 /opt/mysolr1 # cp -a solr-4.10.0 /opt/mysolr2 Multiple Solr instances (1)
  • 11. Create multiple context files with different names, each of them must point to a different solr installation. /var/lib/tomcat6/conf/Catalina/localhost/solrApp1.xml /var/lib/tomcat6/conf/Catalina/localhost/solrApp2.xml Multiple Solr instances (2)
  • 12. Change the context files content, to point to the right solr installation. File solrApp1.xml: <?xml version="1.0" encoding="utf-8"?> <Context docBase="/opt/mysolr1/example/webapps/solr.war" debug="0" crossContext="true"> <Environment name="solr/home" type="java.lang.String" value="/opt/mysolr1/example/solr" override="true"/> </Context> Multiple Solr instances (3)
  • 13. Change the context files content, to point to the right solr installation. File solrApp2.xml: <?xml version="1.0" encoding="utf-8"?> <Context docBase="/opt/mysolr2/example/webapps/solr.war" debug="0" crossContext="true"> <Environment name="solr/home" type="java.lang.String" value="/opt/mysolr2/example/solr" override="true"/> </Context> Multiple Solr instances (4)
  • 14. The Solr schema must have an unique field, identified in the schema.xml file by something like: <uniqueKey>id</uniqueKey> where id is the field defined by: <field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" /> Solr Schema (1)
  • 15. For most of the other fields of the indexed resources, you will use the Solr dynamic fields defined in the scheme like the following ones: <dynamicField name="*_i" type="int" indexed="true" stored="true"/> <dynamicField name="*_is" type="int" indexed="true" stored="true" multiValued="true"/> Solr Schema (2)
  • 16. Solr field types are defined in the schema too: <fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0"/> <fieldType name="float" class="solr.TrieFloatField" precisionStep="0" positionIncrementGap="0"/> Solr Schema (3)
  • 17. Text types can have some magic stuff: <!-- A text field that only splits on whitespace for exact matching of words --> <fieldType name="text_ws" class="solr.TextField" positionIncrementGap="100"> <analyzer> <tokenizer class="solr.WhitespaceTokenizerFactory"/> </analyzer> </fieldType> Solr Schema (4)
  • 18. <fieldType name="text_en" class="solr.TextField" positionIncrementGap="100"> <analyzer type="index"> <tokenizer class="solr.StandardTokenizerFactory"/> <filter [...]/> <!-- +other filters --> </analyzer> <analyzer type="query"> <tokenizer [...]/> <filter [...]/> <!-- +other filters --> </analyzer> </fieldType> Solr Schema (5)
  • 19. Analyzers are components that pre-process input text at index time and/or at search time. It's important to use the same or similar analyzers that process text in a compatible manner at index and query time. For example, if an indexing analyzer lowercases words, then the query analyzer should do the same to enable finding the indexed words. (from https://wiki.apache.org/solr/) Solr Schema (6)
  • 20. Tokenizer examples: ● <tokenizer class="solr.WhitespaceTokenizerFactory"/> ● <tokenizer class="solr.StandardTokenizerFactory"/> ● <tokenizer class="solr.LetterTokenizerFactory"/> ● <tokenizer class="solr.LowerCaseTokenizerFactory"/> Solr Schema (7)
  • 21. Filter examples: ● <filter class="solr.LowerCaseFilterFactory"/> ● <filter class="solr.RemoveDuplicatesTokenFilterFactory"/> ● <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" /> ● <filter class="solr.GermanNormalizationFilterFactory"/> ● <filter class="solr.GermanLightStemFilterFactory"/> Solr Schema (8)
  • 22. Although the schema is already set up, you should really go through it and get rid of all the unnecessary stuff! Get rid of all the fields and types you don’t need, maintainability will be enhanced, and everything will look much clearer! Solr Schema (9)
  • 23. Solr can be indexed in many ways, depending on your application technology. ● In PHP: you can use Solarium, a Solr client library ● In Java: you can use Solrj ● Using Data Import Request Handler Indexing Solr (1)
  • 24. Synchronous indexing: PHP or Java you listen to DataBase insertion, deletion and update, and call the related Solr APIs (by using the libraries, possibly) Indexing Solr (2)
  • 25. Synchronous indexing, pitfalls: What if Solr is down? - find a way to be sure the sync is done! Indexing Solr (3)
  • 26. AJAX Solr loosely follows the Model-view- controller pattern. The ParameterStore is the model, storing the Solr parameters and, thus, the state of the application. The Manager is the controller; it talks to the ParameterStore, sends requests to Solr, and delegates the response to the widgets for rendering. The widgets are the views, each rendering a part of the interface. Ajax-Solr (1)
  • 27. AJAX Solr it’s a javascript application. It offers an autocomplete feature searching in multiple fields (reported in the result list), faceted search based tagcloud, result display Ajax-Solr (2)
  • 29. Use /examples/reuters-requirejs/ as a starting point for your application. In /examples/reuters-requirejs/js/reuters.js set Solr address solrUrl: 'http://localhost:8983/solr/', Ajax-Solr - Deployment (2)
  • 30. In the same reuters.js set the fields to be used. Just before: Manager.addWidget(new AjaxSolr.TagcloudWidget Set the fields var with the fields you want to use in the tag clouds, e.g. var fields = [‘notebook_label_s’,’user_s’]; Ajax-Solr - Deployment (3)
  • 31. Now we set parameters for the facet (used in the tag clouds): var params = { facet: true, 'facet.field': [ 'notebook_label_s', 'user_s'], 'facet.limit': 20, 'facet.mincount': 1, 'f.notebook_label_s.facet.limit': 50, 'f.user_s.facet.limit': 50, Ajax-Solr - Deployment (4)
  • 32. We may add other parameters to the facet query here 'fq': 'basket_id_s:' +basket_id or 'fq': 'my_field_i:8' Ajax-Solr - Deployment (5)
  • 33. In the Manager.addWidget(new AjaxSolr.AutocompleteWidget({ set the fields to be used for the autocomplete : var fields = [‘notebook_label_s’,’predicate_label_s’]; Ajax-Solr - Deployment (6)
  • 34. In the index.html example page everything is already set up. You’ll just need to customize the tagclouds, by adding/modifying the tagcloud tags, like <h2>Notebooks</h2> <div class="tagcloud" id="notebook_label_s"> </div> <h2>Users</h2> <div class="tagcloud" id="user_s"> </div> Ajax-Solr - Deployment (7)
  • 35. One last thing you may want to do, is customize the results output, in the /examples/reuters- requirejs/widgets/ResultWidget.js file, modify the content of: template: function (doc) { [...] } Ajax-Solr - Deployment (8)