Skip to content

Instantly share code, notes, and snippets.

@kevindoran
kevindoran / Category.java
Created February 1, 2013 04:06
Category class for dynamic menu
public class Category {
private String name;
public Category() {
name = "" + Math.random();
}
public List<Category> getChildCategories() {
List<Category> childCategories = new ArrayList<>();
for(int i=0; i<20; i++) {
@kevindoran
kevindoran / solr.xml
Created February 5, 2013 01:27
solr core config
<!-- persistent="true" allows the web interface to make lasting changes to Solr. -->
<solr persistent="true" sharedlib="lib">
<cores adminpath="/admin/cores" host="${host:}" hostcontext="${hostContext:}" hostport="${jetty.port:}" zkclienttimeout="${zkClientTimeout:15000}">
<core default="true" instancedir="auctions" name="auctions">
</core></cores>
</solr>
@kevindoran
kevindoran / exampleSolrDoc.xml
Created February 5, 2013 01:34
Example Solr document
<doc>
<field name="auction_id">54432834</field>
<field name="title">Dell M2012 24" IPS Monitor</field>
<field name="category">monitors</field>
<field name="current_bid">279.95</field>
<field name="end_date">2013-01-06T09:26:04.18Z</field>
<field name="feature">IPS</field>
<field name="feature">Swivel</field>
</doc>
@kevindoran
kevindoran / schema.xml
Created February 5, 2013 01:36
Example Solr schema.
<schema name="example" version="1.5">
<fields>
<field name="_version_" type="long" indexed="true" stored="true" required="true"/>
<field name="auction_id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="title" type="text_en" indexed="true" stored="true" required="true" multiValued="false" />
<field name="category" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="current_bid" type="currency" indexed="true" stored="true" required="true" multiValued="false" />
<field name="end_date" type="date" indexed="true" stored="true" required="true" multiValued="false" />
<field name="feature" type="string" indexed="true" stored="true" required="false" multiValued="true" />
</fields>
@kevindoran
kevindoran / schema.xml
Created February 5, 2013 02:16
Example of copy and dynamic fields in Solr schema
<schema name="example" version="1.5">
<fields>
<field name="title" type="text_en" indexed="true" stored="true" required="true" multiValued="false" />
<field name="category" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="feature" type="string" indexed="true" stored="true" required="false" multiValued="true" />
<field name="allText" type="text_en" indexed="true" stored="false" required="true" multiValued="true" />
</fields>
<copyField source="title" dest="allText" />
<copyField source="category" dest="allText" />
@kevindoran
kevindoran / schemaPart.xml
Created February 5, 2013 02:37
The default text_en fieldType.
<fieldType name="text_en" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory"
ignoreCase="true"
words="lang/stopwords_en.txt"
enablePositionIncrements="true"
/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.EnglishPossessiveFilterFactory"/>
@kevindoran
kevindoran / schemaPart.xml
Last active December 12, 2015 04:08
Effects of multivalued fields in Solr
<!-- What an auction might look like in its original XML form: -->
<auction>
<title>Desktop PC</title>
<feature>
<name>RAM</name>
<value>16 GB</value>
</feature>
<feature>
<name>CPU Frequency</name>
<value>4.5 GHz</value>
@kevindoran
kevindoran / solrconfigPart.xml
Created February 5, 2013 03:36
XML post request handler in Solr
<!-- in solrconfig.xml -->
<requestHandler name="/update" class="solr.UpdateRequestHandler" />
@kevindoran
kevindoran / comparison.xml
Created February 5, 2013 03:43
Comparison between original and solr format
<!-- original XML format: -->
<auction>
<auction_id>54432834</auction_id>
<title>Dell M2012 24" IPS Monitor</title>
<category>monitors</category>
<current_bid>279.95</current_bid>
</auction>
<!-- The format Solr requires: -->
<doc>
@kevindoran
kevindoran / xmlToSolrDoc.xml
Created February 5, 2013 03:49
XSLT file used to convert a XML file to Solr's expected format.
<?xml version="1.0" encoding="UTF-8" ?>
<!-- the 2.0 version of xsl reqires a custom processor to be used. Saxon9he is used, and is
located in Jetty's ext/ folder. This library requires Jetty to be started like so:
java -Djavax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactoryImpl -jar start.jar
-->
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"