More Related Content Similar to Apache Solr (20) Apache Solr2. • What is Solr?
• Solr Architecture
• Install & Configure
• Search, Index, Update & Delete
3. What is Solr ?
• Solr is full text search server with REST-like API
• Document index with JSON, XML, CSV or binary over HTTP
• Query document with HTTP GET
• Receive JSON, XML, CSV or binary result
4. Solr History
• 2004 - Solr was created by Yonik Seeley
• 2006 - Solr was joined in Apache
• 2006 - Solr version 1.1.0. was released
• 2010 - Solr and Lucene merged
• 2012 - Solr version 4.0 was released
• 2015 - Solr version 5.0 was released
• 2016 - Solr version 6.0 was released
5. Solr Features
• Fuzzy & Proximity Search
• Filter Query
• Faceting
• Highlighting
• Stats
• Spellcheck
• Grouping
• Admin Panel
11. schema • uniquekey
• fieldtype
• analyzer
• filter
• tokenizer
• field
• dynamic Field
• copyField
13. Custom Field Type
<fieldType name="text_general" class="solr.TextField”positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" words="stopwords.txt" ignoreCase="true"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.SynonymFilterFactory" expand="true" ignoreCase="true"
synonyms="synonyms.txt"/>
<filter class="solr.StopFilterFactory" words="stopwords.txt" ignoreCase="true"/>
</analyzer>
</fieldType>
20. Faceting • facet.query
• facet.field
• facet.mincount -> f.<field.name>.facet.mincount
• facet.limit -> f.<field.name>.facet.limit
• facet.offset -> f.<field.name>.facet.offset
• facet.sort count, facet.sort index
• tagging & excluding Filter
26. Spelling
spellcheck.q=Keyword&spellcheck=on
"spellcheck": {
"suggestions":
["father",{
"numFound": 3,
"startOffset": 0,
"endOffset": 6,
"origFreq": 20,
"suggestion": [
{"word": "feather","freq": 3},
{"word": "farmer","freq": 4},
{"word": "fisher","freq": 3}
]
}
],
"correctlySpelled": false}
27. Grouping
group=true&group.field=year
"grouped":{
"year":{
"matches":10683,
"groups":[{
"groupValue":1995,
"doclist":{"numFound":361,"start":0,"docs":[
{
"movie_id":"movie_32",
"id":"32",
"name":"12 Monkeys (Twelve Monkeys)",
"year":1995,
"genre":["Sci-Fi",
"Thriller"],
"_version_":1545364353246560258}]
}},
{
"groupValue":1994,
"doclist":{"numFound":307,"start":0,"docs":[
{
"movie_id":"movie_889",
"id":"889",
"name":"1-900 (06)",
"year":1994,
"genre":["Drama",
"Romance"],
"_version_":1545364353356660743}]
}}}
28. Index
Data • post command -c coreName -p port
• Rest API
• SolrJ, Spring Data Solr or Other libraries
• DataImportHandler
29. REST API Sample (XML)
curl -X POST "http://localhost:8080/solr/films/update?commit=true"
-H "Content-Type: text/xml"
-d '
<add>
<doc>
<field name="id">100000</field>
<field name="name">Toy2 Story</field>
</doc>
</add>'
30. REST API Sample (JSON)
curl -X POST 'http://localhost:8983/solr/new_core/update?commit=true'
-H 'Content-Type: application/json'
-d'
[
{
"id": "1",
"name": "movie name 1"
},
{
"id": "1",
"name": "movie name 2"
}
]'
32. Update Data
curl -X POST "http://localhost:8983/solr/new_core/update?commit=true"
-H "Content-Type: text/xml"
-d ‘[{"id":"1","movie_id":{"set":”new_movie_id"}}]'
Editor's Notes Solr 4.0 ( Solr Cloud)
Solr 5.0 ( Standalone Application )
Solr 6.0 ( Parallel queries across solr cloud collections and new jdbc driver for sql interfaces ) <requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">db-data-config.xml</str>
</lst>
</requestHandler>
http://localhost:8080/solr/new_core/select?facet.field={!ex=yearTag}year&facet=on&fq={!tag=yearTag}year:1995&indent=on&q=*:*&rows=0&wt=json
http://localhost:8080/solr/new_core/select?facet.field=year&facet=on&fq=year:1995&indent=on&q=*:*&rows=0&wt=json <requestHandler name="/spell" class="solr.SearchHandler" startup="lazy">
<searchComponent name="spellcheck" class="solr.SpellCheckComponent"> Ngroups, format, limit