Responsive Facets with Apache Solr
-
Upload
brent-lemons -
Category
Documents
-
view
145 -
download
12
description
Transcript of Responsive Facets with Apache Solr
![Page 1: Responsive Facets with Apache Solr](https://reader033.fdocuments.us/reader033/viewer/2022061223/54c66b254a795944538b4580/html5/thumbnails/1.jpg)
Discussion document – Strictly Confidential & Proprietary
Responsive Facets with Apache SolrDallas, TXFebruary 12, 2013
![Page 2: Responsive Facets with Apache Solr](https://reader033.fdocuments.us/reader033/viewer/2022061223/54c66b254a795944538b4580/html5/thumbnails/2.jpg)
Responsive Facets with Apache Solr
2February 12, 2013
Agenda …
What we will cover tonight
• Concept of Facets
• The Problem with RDBMS
• Solr to the Rescue
• Solr by example
• Architecture basics
• Putting data in
• Getting data out
![Page 3: Responsive Facets with Apache Solr](https://reader033.fdocuments.us/reader033/viewer/2022061223/54c66b254a795944538b4580/html5/thumbnails/3.jpg)
Responsive Facets with Apache Solr
3February 12, 2013
Concept of facets…
Sometimes the facets only have groups with values
![Page 4: Responsive Facets with Apache Solr](https://reader033.fdocuments.us/reader033/viewer/2022061223/54c66b254a795944538b4580/html5/thumbnails/4.jpg)
Responsive Facets with Apache Solr
4February 12, 2013
Concept of facets…
Sometimes, they also include a count for the value
![Page 5: Responsive Facets with Apache Solr](https://reader033.fdocuments.us/reader033/viewer/2022061223/54c66b254a795944538b4580/html5/thumbnails/5.jpg)
Responsive Facets with Apache Solr
5February 12, 2013
The Problem with RDBMS…
Easy enough, just attributes of the product…
![Page 6: Responsive Facets with Apache Solr](https://reader033.fdocuments.us/reader033/viewer/2022061223/54c66b254a795944538b4580/html5/thumbnails/6.jpg)
Responsive Facets with Apache Solr
6February 12, 2013
The Problem with RDBMS…
Easy enough, just attributes of the product… Or is it!
![Page 7: Responsive Facets with Apache Solr](https://reader033.fdocuments.us/reader033/viewer/2022061223/54c66b254a795944538b4580/html5/thumbnails/7.jpg)
Responsive Facets with Apache Solr
7February 12, 2013
The Problem with RDBMS…
Easy enough, just attributes of the product… Or is it!
![Page 8: Responsive Facets with Apache Solr](https://reader033.fdocuments.us/reader033/viewer/2022061223/54c66b254a795944538b4580/html5/thumbnails/8.jpg)
Responsive Facets with Apache Solr
8February 12, 2013
The Problem with RDBMS…
Easy enough, just attributes of the product… Or is it!
![Page 9: Responsive Facets with Apache Solr](https://reader033.fdocuments.us/reader033/viewer/2022061223/54c66b254a795944538b4580/html5/thumbnails/9.jpg)
Responsive Facets with Apache Solr
9February 12, 2013
The Problem with RDBMS…
Easy enough, just attributes of the product… Or is it!
![Page 10: Responsive Facets with Apache Solr](https://reader033.fdocuments.us/reader033/viewer/2022061223/54c66b254a795944538b4580/html5/thumbnails/10.jpg)
Responsive Facets with Apache Solr
10February 12, 2013
Solr to the rescue…
We need a better way to organize our data for fast queries
Solr is a standalone search server built on the Lucene Search Library. It offers all the capabilities of the Lucene library and extends the capabilities. Solr interactions are handled through a REST-like API, allowing you to input and retrieve data in a variety of formats.
Solr can run within most servlet containers including Tomcat and Jetty.
• Full-Text Search Capabilities
• Standards Based Open Interfaces – XML, JSON and HTTP
• Linearly scalable, auto index replication, auto failover and recovery
• Near Real-time indexing
• SolrJ library capable of binary over HTTP communication
• Faceted Search and Filtering
![Page 11: Responsive Facets with Apache Solr](https://reader033.fdocuments.us/reader033/viewer/2022061223/54c66b254a795944538b4580/html5/thumbnails/11.jpg)
Responsive Facets with Apache Solr
11February 12, 2013
Solr to the rescue…
Products are inserted into Solr as a Document
• Fields and Dynamic Fields
• Unique Key on a specific field
• Fields are typed
– String is a literal
– Text is a tokenized string
• CopyField allows you to populate multiple fields off a single field insert
![Page 12: Responsive Facets with Apache Solr](https://reader033.fdocuments.us/reader033/viewer/2022061223/54c66b254a795944538b4580/html5/thumbnails/12.jpg)
Responsive Facets with Apache Solr
12February 12, 2013
Solr by example…
Solr utilizes a REST-like interface with XML, JSON and binary capabilities
Let’s look at a few examples…
![Page 13: Responsive Facets with Apache Solr](https://reader033.fdocuments.us/reader033/viewer/2022061223/54c66b254a795944538b4580/html5/thumbnails/13.jpg)
Responsive Facets with Apache Solr
13February 12, 2013
Running Solr
• Embedded
– Makes your application more bloated
– More resource intensive
• Standalone
– Run on it’s own server
– Network traffic hit
– Replication is an option
• SolrCloud
– High availability
– Sharded with replication
– http://bit.ly/TdAJBw
Architecture basics…
![Page 14: Responsive Facets with Apache Solr](https://reader033.fdocuments.us/reader033/viewer/2022061223/54c66b254a795944538b4580/html5/thumbnails/14.jpg)
Responsive Facets with Apache Solr
14February 12, 2013
Architecture basics…
Our environment
![Page 15: Responsive Facets with Apache Solr](https://reader033.fdocuments.us/reader033/viewer/2022061223/54c66b254a795944538b4580/html5/thumbnails/15.jpg)
Responsive Facets with Apache Solr
15February 12, 2013
Architecture basics…
Communicating with Solr
SolrJ
• Java binary communication
• Library that abstracts connection, query formation and response processing
<bean id="solrServer" class="org.apache.solr.client.solrj.impl.LBHttpSolrServer"> <constructor-arg value="${solr.url.primary}"/> </bean>
Inject Server
Inject Search Service <bean id="blSearchService" class="com.vology.core.service.search.VolSearchServiceImpl"> <constructor-arg name="solrServer" ref="${solr.source.primary}" /> </bean>
Utilize SolrJ Library
• ServerContext
• SolrDocument
• SolrQuery
• QueryResponse
![Page 16: Responsive Facets with Apache Solr](https://reader033.fdocuments.us/reader033/viewer/2022061223/54c66b254a795944538b4580/html5/thumbnails/16.jpg)
Responsive Facets with Apache Solr
16February 12, 2013
Putting data in…
How do we get the data into Solr?
Transform fields• Populate transient fields
• Determine terminating object
Query product data from DB• Utilize Hibernate to retrieve relevant products
Populate SolrJ SolrDocument• Java Reflection to get fields we want
• SolrField data from Field
Add SolrDocument• Group into a List<SolrDocument>
• Add full set or incremental
• Commit
![Page 17: Responsive Facets with Apache Solr](https://reader033.fdocuments.us/reader033/viewer/2022061223/54c66b254a795944538b4580/html5/thumbnails/17.jpg)
Responsive Facets with Apache Solr
17February 12, 2013
Getting data out
How do we get the data out of Solr?
Build SolrQuery• Query searchable fields from Field table
• Creates ‘&’ delimited list for qf from Field table
• We utilize a boost value (^100.0)
Add Search Facets• Uses search facet and search facet range tables
• Creates ‘&’ delimited list of facet.field and facet.range
Query on ServerContext• server.query(SolrQuery)
• QueryResponse returned
Populate ProductSearchResult• Set facets
• Set results
• Passed back to SearchController
![Page 18: Responsive Facets with Apache Solr](https://reader033.fdocuments.us/reader033/viewer/2022061223/54c66b254a795944538b4580/html5/thumbnails/18.jpg)
Responsive Facets with Apache Solr
18February 12, 2013
Contact ...
Tell me what you thought!
@brentlemons
slideshare.net/brentlemons
linkedin.com/in/brentlemons
github.com/brentlemons
Do you think this presentation should be at OSCon?
• Tweet @oscon to let them know!