Ajax Solr 是一個使用用戶端Javascript庫實現的基於Solr的應用庫,提供了豐富的應用功能。
Ajax Solr is a client-side JavaScript library that can access Solr via its REST-like interface. Solr is not properly a database, but a search server; however it is the main data source for a search-based application. The result of using Ajax Solr for the user interface is literally having a JDBC (or PDO) Api available in the browser, which can make queries and change the results displayed basing on events generated by the user.
官方首頁和具體的介紹
https://github.com/evolvingweb/ajax-solr
http://www.renren.it/a/JAVAbiancheng/JAVAzonghe/20100909/client-applications-ajax-solr.html
http://java.dzone.com/articles/client-applications-ajax-solr
例子Reuters tutorial:
https://github.com/evolvingweb/ajax-solr/wiki/reuters-tutorial
http://wenku.baidu.com/view/6830cd10f18583d04964590d.html
例子的下載:http://github.com/evolvingweb/ajax-solr/zipball/gh-pages
解壓下載的檔案,其中examples就是如下的具體效果,docs是庫的API Docs說明,非常詳細;lib就是這個庫的javascript原始碼
如下是每個例子的具體效果,可見關於搜尋的各個方面在這個庫基礎都有豐富的體現,對於我們的常見應用有借鑒意義。
【如下的例子分步的差別使用紅色框標註】
· Step 1: Talk to Solr
· Step 2: Add a results widget
· Step 3: Add a pager widget
· Step 4: Add a tagcloud widget
· Step 5: Display the current filters
· Step 6: Add a free-text widget
· Step 7: Add an autocomplete widget
· Step 8: Add a map widget
· Step 9: Add a calendar widget
Step 10: Extra credit
基礎
以上應用的具體服務都是基於Solr的服務返回的Json資料,具體請求類似如下:
http://evolvingweb.ca/solr/reuters/select?facet=true&q=*%3A*&facet.field=topics&facet.field=organisations&facet.field=exchanges&facet.field=countryCodes&facet.limit=20&facet.mincount=1&f.topics.facet.limit=50&f.countryCodes.facet.limit=-1&facet.date=date&facet.date.start=1987-02-26T00%3A00%3A00.000Z%2FDAY&facet.date.end=1987-10-20T00%3A00%3A00.000Z%2FDAY%2B1DAY&facet.date.gap=%2B1DAY&json.nl=map&wt=json&json.wrf=jsonp1313733083156&_=1313733083258
http://evolvingweb.ca/solr/reuters/select?q=*:*&rows=0&facet=true&facet.limit=-1&facet.mincount=1&json.nl=map&facet.field=topics&facet.field=organisations&facet.field=exchanges&wt=json&json.wrf=jsonp1313733083157&_=1313733084113