![Page 2: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/2.jpg)
http://0rz.tw/5kl2E
![Page 3: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/3.jpg)
關於我@gasolwu
![Page 4: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/4.jpg)
不嫌Java囉唆
![Page 5: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/5.jpg)
又喜歡Python的簡捷
![Page 6: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/6.jpg)
且對Android有愛
![Page 7: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/7.jpg)
開始進入正題
![Page 8: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/8.jpg)
你的網站有內容了還不夠!
![Page 9: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/9.jpg)
你的網站有內容了還不夠!
還要讓使用者找的到才行...
![Page 10: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/10.jpg)
搜尋的重要性!
交給Google就行了嗎?
![Page 11: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/11.jpg)
Solr and Cassandra?
![Page 12: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/12.jpg)
事情是這樣的...
![Page 13: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/13.jpg)
使用者建議愈來愈多使用者嵌外站服務只有個人,沒有全站PV Up Up
![Page 14: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/14.jpg)
那就做吧,Solution?
![Page 15: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/15.jpg)
Lucene + Solr
吃大蒜哪有不嘴臭的道理
![Page 16: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/16.jpg)
Solr
created by Yonik Seeley at CNET NetworksContributed to Apache in January 2006the Lucene and Solr projects merged In March 2010current 1.4.1 (with lucene 2.9.3)Web admin interfacemany feature.
![Page 17: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/17.jpg)
Powerful full-text searchhttp://localhost:8080/solr/select?q=title:coscup
![Page 18: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/18.jpg)
趴xml太麻煩?
水管太小?
![Page 19: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/19.jpg)
JSON result/select?q=title:coscup&wt=json
{"response":{"numFound":21, "start":0, "maxScore":15.267826, "docs":[ { "id":"17206-24959116", "title":"VIM Hacks - c9s在COSCUP的講題", "score":4.7711954}, { "id":"1893496-27550711", "title":"COSCUP 09' 精簡心得,COSCUP 萬歲!", "score":8.096988}, { "id":"232580-24907067", "title":"COSCUP 2009開源人年會參後心得", "score":4.7711954}, { "id":"232580-24906103", "title":"COSCUP 2009開源人年會參後心得", "score":4.7711954}, { "id":"630252-29042632", "title":"COSCUP 2009 開源人年會小記", "score":4.7711954}] }}
![Page 20: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/20.jpg)
Multiple keyword/select?q=title:coscup+title:心得&wt=json
{"response":{ "numFound":3, "start":0, "maxScore":8.46245, "docs":[ { "id":"1893496-27550711", "title":"COSCUP 09' 精簡心得,COSCUP 萬歲!", "score":8.46245}, { "id":"232580-24907067", "title":"COSCUP 2009開源人年會參後心得", "score":5.259093}, { "id":"232580-24906103", "title":"COSCUP 2009開源人年會參後心得", "score":5.259093}] }}
![Page 21: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/21.jpg)
Filter Query
/select?q=title:coscup&fq=category:2
![Page 22: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/22.jpg)
Range Query/select?q=title:coscup+date:[* TO NOW]
/select?q=mac+mini+price:[0 TO 19900]
![Page 23: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/23.jpg)
Query Boost/select?q=title:老虎^5+OR+title:老鼠
Index Boost<add> <doc boost="2.5"> <field name="id">1234567</field> <field name="title" boost="2.0">Coscup 2010</field></add>
![Page 24: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/24.jpg)
Highlighting
"highlighting":{ "1893496-27550711":{ "title":["<em>COSCUP</em> 09' 精簡<em>心得</em>,<em>COSCUP</em> 萬歲!"]}, "232580-24907067":{ "title":["<em>COSCUP</em> 2009開源人年會參後<em>心得</em>"]}, "232580-24906103":{ "title":["<em>COSCUP</em> 2009開源人年會參後<em>心得</em>"]}
/select?q=title:coscup+title:心得&hl=true&hl.fl=title
![Page 25: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/25.jpg)
Facet/select?q=title:coscup+title:心得&facet=true&facet.fl=category
![Page 26: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/26.jpg)
Replicationmaster
<requestHandler name="/replication" class="solr.ReplicationHandler" > <lst name="master"> <str name="replicateAfter">commit</str> <str name="confFiles">schema.xml,stopwords.txt</str> </lst></requestHandler>
slave<requestHandler name="/replication" class="solr.ReplicationHandler" > <lst name="slave"> <str name="masterUrl">http://foo:8080/solr/replication</str> <str name="pollInterval">02:30:00</str> </lst></requestHandler>
![Page 27: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/27.jpg)
Others
Caching (filter, query, document)Web administration interfaceDistributed search (sharding)Spell Checking,More Like This
![Page 28: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/28.jpg)
What is Cassandra?
Key-value store (with BigTable like structure)highly scalable and availabledecentralized and distributedEventually consistent2 famous paper
BigTable (data model)Dynamo (distribution architecture)
![Page 29: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/29.jpg)
![Page 30: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/30.jpg)
![Page 31: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/31.jpg)
![Page 32: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/32.jpg)
Partitioning
RandomPartitionerTokens are integers in the rage 0-2^127md5(Key) -> Token
OrderPreservingPartitionerTokens are UTF8 strings
![Page 33: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/33.jpg)
Read/Write
![Page 34: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/34.jpg)
Data Model
Keyspace (like database)ColumnFamily (like table)
Standard or Super two levels of indexes (key and column name)
Column and subcolumn sortingSpecify your own comparator
TimeUUIDLexicalUUID UTF8LongBytes
![Page 35: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/35.jpg)
ConsistencyWrite
ZERO - asynchronouslyANYONEQUORUM - N / 2 + 1ALL
ReadONE - first nodeQUORUM - recent timestamp
If W + R > N, you will have consistencyW=1, R=NW=N, R=1W=Q, R=Q where Q = N / 2 + 1
![Page 36: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/36.jpg)
R+W>N guarantees overlap of read and write quorums
![Page 37: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/37.jpg)
Related Post Architecture
![Page 38: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/38.jpg)
More Like This/select?q=id:12345678&mlt=true&mlt.fl=title
![Page 39: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/39.jpg)
MLT paramaters
mlt.mintf - minimum term frequency, default 2mlt.mindf - minimum document frequency, default 5max.minwl - minimum word length, default 0mlt.maxwl - maximum word length, default 0mlt.maxqt - maximum of query terms, default 25mlt.maxntp - maximum number of tokens to parse, default 5000mlt.boost - default falsemlt.count - The number of similar documents to return for each resultmlt.interestingTerms - one of "list" or "details", this will show what interesting terms are used for query.
<field name="title" ... termVectors="true" />
![Page 40: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/40.jpg)
MLT Algorithmcompute all terms frequency.
![Page 41: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/41.jpg)
sort by tf*idf
![Page 42: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/42.jpg)
BooleanClause.Occur
1. MUST2. MUST_NOT3. SHOULD
![Page 43: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/43.jpg)
Conclusiondon't just thinklog everything
INFO: [] webapp=/blogarticle path=/relate params={id=2250592-7594244&mlt.fl=body&mlt.debug=true&mlt.maxqt=5&type=site&wt=json&fq=status:2&fq=spam:false&fq=enable:true&rows=20} cassandra=3 ms. terms={coscup 開源 人年 舞會 2010 } status=0 QTime=149
use *Factory<analyzer type="index" class="org.apache.lucene.analysis.cjk.CJKAnalyzer"> <tokenizer class="org.apache.lucene.analysis.cjk.CJKTokenizer" /> <filter class="solr.LowerCaseFilterFactory"/> ...more</analyzer>
HTML kill you.
![Page 44: Solr on Cassandra - COSCUP...Solr created by Yonik Seeley at CNET Networks Contributed to Apache in January 2006 the Lucene and Solr projects merged In March 2010 current 1.4.1 (with](https://reader034.vdocuments.net/reader034/viewer/2022042115/5e91ec8ead9c7301a90ee270/html5/thumbnails/44.jpg)
cassandra-munin-plugin
http://github.com/jamesgolick/cassandra-munin-plugins