• 検索結果がありません。

jar と 差し替えます

ドキュメント内 ファイル置き場 日本Cassandraコミュニティ (ページ 35-49)

org/apache/lucene/util/

2.9.1. jar と 差し替えます

QueryParser

のデフォルトオペ レータを

AND

にして、再チャレンジ!!

ShopSearchDemo.java:

QueryParser qp =

new QueryParser(Version.LUCENE_CURRENT, "name", analyzer);

qp.setDefaultOperator( Operator.AND );

$ ./run_shop.sh -search name: 丸の内

Picked up _JAVA_OPTIONS: -Dfile.encoding=UTF-8

12:08:03,436 INFO CassandraProxyClient:145 - Connected to cassandra at 127.0.0.1:9160

+name: 丸の +name: の内

18:03:39,127 DEBUG LucandraTermEnum:237 - Found 2 keys in range:OxSo2Td8name 丸の to in 109ms

18:03:39,127 DEBUG LucandraTermEnum:246 - name 丸の has 115 18:03:39,128 DEBUG LucandraTermEnum:246 - name 丸ノ has 10 18:03:39,130 DEBUG LucandraTermEnum:285 - loadTerms:

OxSo2Td8name 丸の (3) took 112ms

18:03:39,131 INFO IndexReader:153 - docFreq() took: 222ms 18:03:39,189 DEBUG LucandraTermEnum:237 - Found 2 keys in range:OxSo2Td8name の内 to in 57ms

18:03:39,189 DEBUG LucandraTermEnum:246 - name の内 has 115 18:03:39,190 DEBUG LucandraTermEnum:246 - name の勘 has 2 18:03:39,190 DEBUG LucandraTermEnum:285 - loadTerms:

OxSo2Td8name の内 (3) took 58ms

18:03:39,190 INFO IndexReader:153 - docFreq() took: 59ms

18:03:39,196 DEBUG LucandraTermEnum:176 - Found OxSo2Td8name 丸の in cache

18:03:39,202 DEBUG LucandraTermEnum:176 - Found OxSo2Td8name の内 in cache

Search matched: 115 item(s)

09:52:16,739 DEBUG IndexReader:293 - Document read took:

10ms1. Luxor 丸の内

http://r.gnavi.co.jp/g763393/ ¥9000

09:52:16,741 DEBUG IndexReader:293 - Document read took: 1ms 2. the Pantry 丸の内店

http://r.gnavi.co.jp/g763381/ ¥1300

09:52:16,743 DEBUG IndexReader:293 - Document read took: 1ms 3. MAISON・BARSAC 丸の内

http://r.gnavi.co.jp/g763375/ ¥5500

09:52:16,750 DEBUG IndexReader:293 - Document read took: 2ms 4. 丸の内 やんも

http://r.gnavi.co.jp/g763373/ ¥8000

09:52:16,751 DEBUG IndexReader:293 - Document read took: 1ms 5. Vinpicoeur ~丸の内~

http://r.gnavi.co.jp/g763372/ ¥3500

09:52:16,753 DEBUG IndexReader:293 - Document read took: 1ms 6. DEAN&DELUCA ~丸の内~

http://r.gnavi.co.jp/g763365/ ¥1500

09:52:16,755 DEBUG IndexReader:293 - Document read took: 2ms 7. S.Stefano ~丸の内~

http://r.gnavi.co.jp/g763359/ ¥4500 : :

おお、なんかできてるっぽい

ソートも試してみる

sort

オプションを指定した場合に、

IndexSearcher.search()

メソッド にて

budget(

予算

)

フィールド値の降順 でソートされるようにしてみます

動かしてみます

ShopSearchDemo.java:

TopDocs docs = indexSearcher.search(q, null, 10,

new Sort(new SortField("budget", SortField.INT, true)));

$ ./run_shop.sh -search name: 丸の内 sort Search matched: 115 item(s)

09:59:17,396 DEBUG IndexReader:293 - Document read took:

9ms1. レストラン モナリザ 丸の内店 ~丸ビル~

http://r.gnavi.co.jp/g763345/ ¥10000

09:59:17,398 DEBUG IndexReader:293 - Document read took:

1ms2. センチュリーコート丸の内

http://r.gnavi.co.jp/g038917/ ¥10000

09:59:17,399 DEBUG IndexReader:293 - Document read took:

1ms3. Luxor 丸の内

http://r.gnavi.co.jp/g763393/ ¥9000

09:59:17,401 DEBUG IndexReader:293 - Document read took:

1ms4. 丸の内 やんも

http://r.gnavi.co.jp/g763373/ ¥8000

09:59:17,402 DEBUG IndexReader:293 - Document read took:

1ms5. たまさか 丸の内店

http://r.gnavi.co.jp/e533319/ ¥8000

09:59:17,403 DEBUG IndexReader:293 - Document read took:

1ms6. ワインショップエノテカ丸の内 ザ・ラウンジ

http://r.gnavi.co.jp/g763382/ ¥6300

09:59:17,405 DEBUG IndexReader:293 - Document read took:

1ms7. 寿し屋の勘八 旬 ~丸の内~

http://r.gnavi.co.jp/g763366/ ¥6000 :

ソートされてるっぽい

まとめ

わかったこと

1

Lucandra

は謳い文句通り

Lucene

のバックエンドに

Cassandra

を採用 したものであり、アプリケーションは

Lucene

の資産

(API)

をほぼそのま ま利用することができる

# PhraseQuery

は要調査

わかったこと

2

Lucene

の機能を十分に使うには、

OrderPreservingPartitioner

を選 択する必要がある

Partitioner

は現状

Cluster

で共通 であり

RandomPartitoner

のシンプルで 効果的なデータ分散の恩恵を受けら れないので、共用環境への導入は要 検討

わかったこと

3

Cassandra

の内部特性を利用するこ とでインデックスの最適化を不要とし、

リアルタイム性を高める構造である

Twitter

クライアントや

RSS

リー ダーのような、ユーザーごとにイン デックスが分かれていて総データ量 が多く、

即時に検索が必要な場面に向いてい ると思われる

わかったこと

4

当然だが、

Java

でしか使えない

他環境では、同梱の

Solrandra

を 使って

HTTP

で利用するのだろう

Java

でも

SolrJ

を使って

Solr

のイ ンデックス管理、キャッシュ機構を 利用するのがベターなのかも

今後の課題

もう

Lucene/Solr

強したら?

Solrandra

ベースでの実用 データとパフォーンス検

RandomPartitioner

での動作検

PhraseQuery . . .

おしまい

参考

ドキュメント内 ファイル置き場 日本Cassandraコミュニティ (ページ 35-49)

関連したドキュメント