Permalink
Newer
Older
100644 80 lines (53 sloc) 3.15 KB
1
# Slashem (SolrRogue)
2
3
Slashem (SolrRogue) is a type-safe internal Scala DSL for constructing and
4
executing find requests against SOLR. It is a rogue-like for solr. It is not
5
currently full expressive to SOLR's query functionality, but covers the main
6
use cases that we encountered.
7
8
## Building and Installation
9
10
Use sbt (simple-build-tool) to build:
11
12
$ sbt clean update package
13
14
The finished jar will be in 'target/'.
15
16
## Hooks to overload certain features
17
18
Slashem provides two main hooks for extension. Most people will probably
19
wish to overload the default logging mechanism which throws away everything.
20
To do this simply implement the SolrQueryLogger trait and set the logger param
21
on your Schema objects to your custom logger.
22
23
The other hook is only useful if you are using Solr for geospatail information,
24
we provide a trait called SolrGeoHash which has two required functions, namely
25
coverString and rectCoverString. Most people will not need to implement this.
26
27
### Multiple Solr cores & non-stanrd query paths
28
29
Support for multiple cores is done by overriding "core" in the model (wich is an Option[String]).
30
If you have a non-standard query path you can override queryPath in your model.
31
32
## Examples
34
[QueryTest.scala](https://github.com/foursquare/slashem/blob/master/src/test/scala/com/foursquare/slashem/QueryTest.scala) contains sample queries and shows the corresponding query.
35
[SolrRogueTest.scala](https://github.com/foursquare/slashem/blob/master/src/test/scala/com/foursquare/slashem/SolrRogueTest.scala) countains some sample records.
37
A basic query against the SUserTest might look something like
38
39
val q = SUserTest where (_.fullname eqs "jon")
40
Mar 31, 2012
41
This would do a phrase search for "jon" against the fullname field in SUserTest.
42
A more complex query might specify a different query parser like so:
43
44
val q = SUserTest where (_.fullname eqs "holden") useQueryType("edismax")
45
46
Frequently with edismax queries you want to run your query against multiple fields
47
and or boost queries which match the entire phrase. The followingis an example of how
48
to do this:
49
50
val q = SVenueTest where (_.default contains lols) useQueryType("edismax") phraseBoost(_.text, 1) phraseBoost(_.name,200) phraseBoost(_.aliases,25) queryField(_.text) queryField(_.ngram_name, 0.2) queryField(_.tags, 0.01) tieBreaker(0.2)
51
52
53
## Dependencies
54
55
lift, joda-time, junit, finagle, jackson. These dependencies are managed by
56
the build system. Note: some of the transitive dependencies may fail to resolve
57
from the central maven. If you are using sbt you can fix this by adding
59
ivyXML := (
60
<dependencies>
61
<exclude module="jmxtools"/>
62
<exclude module="jmxri"/>
63
</dependencies>
64
)
66
## Warnings still a very early version. There are likely bugs (sorry!). Let us know
67
if you find any. While we can't promise timely fixes, it will help :)
68
69
## Maintainers
70
71
Slashem (SolrRogue) was initial developed by Foursquare Labs for internal use.
72
The majority of our solr related calls at Foursquare go through this library.
73
The current maintainers are:
74
75
- Jon Shea jonshea@foursquare.com
76
- Govind Kabra govind@foursquare.com
77
- Holden Karau holden@foursquare.com
78
- Adam Alix aalix@foursquare.com
79
80
Contributions welcome!