You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by Apache Wiki <wi...@apache.org> on 2009/08/26 03:35:53 UTC

[Solr Wiki] Update of "SolrJS" by HossMan

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.

The following page has been changed by HossMan:
http://wiki.apache.org/solr/SolrJS

The comment on the change is:
TOC, header normalizing, and intro para cleanup

------------------------------------------------------------------------------
- == About ==
- 
- SolrJs is a javascript client library that is topic of a 2008 google summer of code project. It is currently work in progress, this page is intended to show the project's status, some technical documentation and a collection of thoughts about future features.  
+ SolrJS is a javascript client library that was initially developed as a 2008 google summer of code project. It is currently work in progress, this page is intended to show the project's status, some technical documentation and a collection of thoughts about future features.  
  
+ <!> ["Solr1.4"]
+ 
+ [[TableOfContents]]
+ 
- == Online example and docs ==
+ = Online example and docs =
  
- Refer to [http://solrjs.solrstuff.org/] to view an online example and online jsdocs. Note that both example and docs can easily be created locally in trunk using ant. 
+ Refer to [http://solrjs.solrstuff.org/] to view an online example and online jsdocs. Note that both example and docs can easily be created locally using ant. 
+ 
+ = Development =
  
  == Source code ==
  
- In the current trunk (Solr 1.4. SNAPSHOT) solrjs found its home in solr's svn under client/javascript. Source code can be located at [http://svn.apache.org/repos/asf/lucene/solr/trunk/client/javascript/]
+ solrjs can be found in Solr releases under client/javascript.  The latest development code can be located at [http://svn.apache.org/repos/asf/lucene/solr/trunk/client/javascript/]
  
- == Creating the docs ==
+ == Creating the documentation ==
  
  We use jsdoc ([http://jsdoc.sourceforge.net/]) to create JavaDoc like documentation. Just go to client/javascript, execute "ant docs" and point to "client/javascript/dist/doc/index.html".
  
@@ -35, +39 @@

  
  
  
- == Architectural Overview ==
+ = Architectural Overview =
  
  The library is written using the javascript toolkit jQuery [http://jquery.com/] (minmal version 1.2.5). After distribution, SolrJS is included in one additional javascript file "solrjs.js". The idea is to create several (reusable and extensible) "widgets" that represent solr queries. A widget is a javascript object that is responsible for creating the according solr query as well as render the result from the server to html. One manager object acts as a container that holds these widgets, performs the actual query using jQueries getJSON [http://docs.jquery.com/Ajax/jQuery.getJSON#urldatacallback] method. This method creates a dynamic script tag, making cross-domain solr requests possible. 
  
@@ -52, +56 @@

  
  For distribution, there is a small ant build script provided taht creates one single js file out of these snippets. Just run "ant dist". In the future, there might be some js compression steps included.
  
- == Examples and source code ==
+ = Examples and source code =
  
  The best way to get an idea how a widget may look like and how it can be integrated into html is to explore the documented source code and the test*.html example pages at [http://solrstuff.org/svn/solrjs/trunk]. Use "ant testsolr-import" to get some testdata and "ant testsolr start" to start the included testserver. 
  
  Despite this, I'll try to describe some important implementation further on this page.
  
+ /!\ :TODO: /!\ ... is this section still relevant? solrstuff.org and explanation of building the reuters demo are already mentioned in above sections.
  
+ 
+ ? ? ? 
+ 
+ 
- == Implementation ==
+ = Implementation =
  
- === Javascript matters ===
+ == Javascript matters ==
  
  All SolrJS objects are created inside the jQuery.solrjs namspace. Given JQueries support for overriding the $() function, it is easily possible to use SolrJS alongside other javascript toolkits like prototype or custom javascript code.
  
@@ -73, +82 @@

  }}}
  After that, all SolrJS objects are accessible using $sj.solrjs.* 
  
- === The manager object ===
+ == The manager object ==
  
  The manager object acts as "Controller" for the user input. It holds a state of the current solr query. The current query is represented by QueryItems objetcs. A query item simply is a field:value pair. A user may select or deselect multiple items. In the current work in progress, all query itemsa are concatinated using "AND" operators. More complex query generation may be implemented in the future. The manager currently provides the following methods:
  
@@ -83, +92 @@

   * doRequest(start): performs the actual solr requests
   * doRequestAll(): clears queryItems and requests all documents
  
- ==== How a query request works ====
+ === How a query request works ===
  
  Every widget implements a "getSolrUrl" method and performs its own http request. It also has to provide a "handleResult" method that gets the json data response to render. So if a user changes the selection:
  
@@ -93, +102 @@

   * json or html data is returned to the widget and widget.handleResponse(data) is called.
  
  
- === Widget Inheritance ===
+ == Widget Inheritance ==
  
  A main goal of the implementation was to create clean easy to understand code that can be easily extended by other developers. So I introduced a small OO inheritance pattern inspired by this thread [http://groups.google.com/group/jquery-dev/msg/12d01b62c2f30671] and created the factory method:
  
@@ -155, +164 @@

  }}}
  
  
- === Example for an easily customized widget: ExtensibleResultWidget ===
+ == Example for an easily customized widget: ExtensibleResultWidget ==
  
  The ExtensibleResultWidget is a showcase of a flexible widget. It provides 2 abstract methods: 
  
@@ -204, +213 @@

  
  }}}
  
- == Ideas for widgets ==
+ = Ideas for widgets =
  
  Some of this widgets will be implemented during this years Summer of Code and weill be provided alongode the framework.
  
@@ -221, +230 @@

  
  Feel free to extend this list.
  
- == Security concerns ==
+ = Security concerns =
  
  As we have to access the solr web app directly to get the json data, a discussion about security was raised on the user list. See Ryan's posting about a single, restricted request handler that only allows selects (NO updates and deletes) [http://www.nabble.com/Announcement-of-Solr-Javascript-Client-to17462581.html#a17462581]. This "ProxyServlet" even could check and modify some parameters to avoid dos attacks or similar (eg. restricting &rows= to a reasonable maximum). Using the jQuery-getJSON method makes it possible to create cross site  json requests, so we even can attach this restricted read-only url path to the solr webapp. Every user may then point the javascript client to eg.http://solrserver/readonly/