Author: ryan
Date: Mon Dec 15 17:03:00 2008
New Revision: 726901
URL: http://svn.apache.org/viewvc?rev=726901&view=rev
Log:
SOLR-868 -- updating javascript example
Added:
lucene/solr/trunk/contrib/javascript/example/core/
lucene/solr/trunk/contrib/javascript/example/core/testClientside.html
lucene/solr/trunk/contrib/javascript/example/core/testServerside.html
lucene/solr/trunk/contrib/javascript/example/reuters/importer/
lucene/solr/trunk/contrib/javascript/example/reuters/importer/java/
lucene/solr/trunk/contrib/javascript/example/reuters/importer/java/org/
lucene/solr/trunk/contrib/javascript/example/reuters/importer/java/org/apache/
lucene/solr/trunk/contrib/javascript/example/reuters/importer/java/org/apache/solr/
lucene/solr/trunk/contrib/javascript/example/reuters/importer/java/org/apache/solr/solrjs/
lucene/solr/trunk/contrib/javascript/example/reuters/importer/java/org/apache/solr/solrjs/ReutersService.java
lucene/solr/trunk/contrib/javascript/example/reuters/testdata/
lucene/solr/trunk/contrib/javascript/example/reuters/testdata/download-dataset.sh
(with props)
lucene/solr/trunk/contrib/javascript/example/reuters/testdata/sample.sgm
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/conf/
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/conf/admin-extra.html
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/conf/elevate.xml
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/conf/protwords.txt
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/conf/schema.xml
(with props)
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/conf/scripts.conf
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/conf/solrconfig.xml
(with props)
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/conf/spellings.txt
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/conf/stopwords.txt
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/conf/synonyms.txt
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/conf/velocity/
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/conf/velocity/VM_global_library.vm
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/conf/velocity/browse.vm
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/conf/velocity/header.vm
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/conf/velocity/hit.vm
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/conf/velocity/main.css
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/conf/xslt/
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/conf/xslt/example.xsl
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/conf/xslt/example_atom.xsl
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/conf/xslt/example_rss.xsl
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/conf/xslt/luke.xsl
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/lib/
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/lib/apache-solr-velocity-1.4-dev.jar
(with props)
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/lib/commons-collections-3.2.jar
(with props)
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/lib/commons-lang-2.4.jar
(with props)
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/lib/solrjs-1.4-dev-templates.jar
(with props)
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/lib/velocity-1.6-beta2.jar
(with props)
lucene/solr/trunk/contrib/javascript/example/reuters/testsolr/solr/lib/velocity-tools-2.0-beta2.jar
(with props)
lucene/solr/trunk/contrib/javascript/example/reuters/web/
lucene/solr/trunk/contrib/javascript/example/reuters/web/images/
lucene/solr/trunk/contrib/javascript/example/reuters/web/images/contenth2.gif
(with props)
lucene/solr/trunk/contrib/javascript/example/reuters/web/images/header.gif
(with props)
lucene/solr/trunk/contrib/javascript/example/reuters/web/images/sidebarh2.gif
(with props)
lucene/solr/trunk/contrib/javascript/example/reuters/web/index.html
lucene/solr/trunk/contrib/javascript/example/reuters/web/style.css
Removed:
lucene/solr/trunk/contrib/javascript/example/testClientside.html
Modified:
lucene/solr/trunk/contrib/javascript/build.xml
Modified: lucene/solr/trunk/contrib/javascript/build.xml
URL:
http://svn.apache.org/viewvc/lucene/solr/trunk/contrib/javascript/build.xml?rev=726901&r1=726900&r2=726901&view=diff
==============================================================================
--- lucene/solr/trunk/contrib/javascript/build.xml (original)
+++ lucene/solr/trunk/contrib/javascript/build.xml Mon Dec 15 17:03:00 2008
@@ -80,33 +80,52 @@
<arg value="-p"/>
</java>
</target>
-
- <!-- import current solr.war to example -->
- <target name="example-init" depends="dist">
- <copy file="../../dist/apache-solr-${version}.war"
tofile="example/testsolr/webapps/solr.war"/>
- <copy todir="example/testsolr/solr/lib" overwrite="true">
- <fileset dir="../velocity/src/main/solr/lib/"/>
- </copy>
- <copy file="dist/solrjs-${version}-templates.jar"
todir="example/testsolr/solr/lib"/>
- </target>
-
- <!-- start server
- <target name="example-start">
- <java jar="example/testsolr/start.jar" fork="true" failonerror="true"
dir="example/testsolr/" />
- </target>
- -->
- <!-- import testdata (server has to be online)
- <target name="example-import">
- <java jar="example/testdata/reutersimporter.jar" fork="true"
failonerror="true" dir="example/testdata/">
- <arg value="http://localhost:8983/solr/"/>
- <arg value="." />
- </java>
- </target>
- -->
-
- <target name="example" depends="build"/>
+ <!--+
+ | Reuters example
+ +-->
+
+ <!-- start solr server, using example/reuters/testsolr/solr -->
+ <target name="reuters-start">
+ <copy todir="example/reuters/testsolr/solr/lib" overwrite="true">
+ <fileset dir="../velocity/src/main/solr/lib/" />
+ </copy>
+ <copy file="dist/solrjs-${version}-templates.jar"
todir="example/reuters/testsolr/solr/lib" />
+ <java jar="../../example/start.jar" fork="true" failonerror="true"
dir="../../example">
+ <sysproperty key="solr.solr.home"
value="../contrib/javascript/example/reuters/testsolr/solr"/>
+ </java>
+ </target>
+
+ <!-- import testdata (server has to be online) -->
+ <target name="reuters-import">
+ <javac srcdir="example/reuters/importer/java">
+ <classpath>
+ <fileset dir="../../lib">
+ <include name="*.jar"/>
+ </fileset>
+ <fileset dir="../../dist">
+ <include name="*.jar"/>
+ </fileset>
+ </classpath>
+ </javac>
+ <java classname="org.apache.solr.solrjs.ReutersService" fork="true"
dir="example/reuters/testdata">
+ <arg value="http://localhost:8983/solr/" />
+ <arg value="." />
+ <classpath>
+ <fileset dir="../../lib">
+ <include name="*.jar"/>
+ </fileset>
+ <fileset dir="../../dist">
+ <include name="*.jar"/>
+ </fileset>
+ <fileset dir="../../dist/solrj-lib">
+ <include name="*.jar"/>
+ </fileset>
+ <path location="example/reuters/importer/java"/>
+ </classpath>
+ </java>
+ </target>
<!-- do nothing for now, required for generate maven artifacts -->
<target name="build"/>
Added: lucene/solr/trunk/contrib/javascript/example/core/testClientside.html
URL:
http://svn.apache.org/viewvc/lucene/solr/trunk/contrib/javascript/example/core/testClientside.html?rev=726901&view=auto
==============================================================================
--- lucene/solr/trunk/contrib/javascript/example/core/testClientside.html
(added)
+++ lucene/solr/trunk/contrib/javascript/example/core/testClientside.html Mon
Dec 15 17:03:00 2008
@@ -0,0 +1,75 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<html>
+<head>
+ <style type="text/css">
+ body { font-family: Arial, sans; font-size: 0.8em}
+ </style>
+
+ <script src="../../lib/jquery/jquery-1.2.6.js"></script>
+ <script src="../../src/core/Core.js"></script>
+ <script src="../../src/core/QueryItem.js"></script>
+ <script src="../../src/core/Manager.js"></script>
+ <script src="../../src/core/AbstractWidget.js"></script>
+ <script src="../../src/core/AbstractServerSideWidget.js"></script>
+ <script src="../../src/core/AbstractClientSideWidget.js"></script>
+ <script src="../../src/clientside/ExtensibleResultWidget.js"/></script>
+ <script src="../../src/clientside/FacetWidget.js"/></script>
+ <script>
+ var $sj = jQuery.noConflict();
+ </script>
+
+
+ <script>
+ var solrjsManager;
+ $sj(document).ready(function(){
+ solrjsManager = new
$sj.solrjs.Manager({solrUrl:"http://localhost:8983/solr/select"});
+ // a custom result widget
+ var resultWidget = new $sj.solrjs.ExtensibleResultWidget({
+ id:"result",
+ target:"#result",
+ rows:20,
+ renderResult : function(docs, pageSize, offset) {
+ var container = jQuery("<div/>");
+ $sj.each(docs, function(i, item) {
+ jQuery("<h3/>").html(item["id"]).appendTo(container);
+ if (item["cat"] != null) {
+ jQuery("<p/>").html(item["cat"].toString()).appendTo(container);
+ }
+ jQuery("<hr/>").appendTo(container);
+ });
+ container.appendTo(this.target);
+ }
+ });
+
+ solrjsManager.addWidget(resultWidget);
+ solrjsManager.addWidget(new $sj.solrjs.FacetWidget({id:"cat",
target:"#cat", fieldName:"cat"}));
+ solrjsManager.doRequestAll();
+ });
+ </script>
+ <style>img{ height: 100px; float: left; }</style>
+</head>
+<body>
+ <div id="facets" style="float:left;width:300px;">
+ <h3 style="margin-top:0px">cat</h3>
+ <div id="cat"></div>
+ </div>
+ <div id="result" style="margin-left:300px;"></div>
+</body>
+</html>
Added: lucene/solr/trunk/contrib/javascript/example/core/testServerside.html
URL:
http://svn.apache.org/viewvc/lucene/solr/trunk/contrib/javascript/example/core/testServerside.html?rev=726901&view=auto
==============================================================================
--- lucene/solr/trunk/contrib/javascript/example/core/testServerside.html
(added)
+++ lucene/solr/trunk/contrib/javascript/example/core/testServerside.html Mon
Dec 15 17:03:00 2008
@@ -0,0 +1,69 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<html>
+<head>
+ <style type="text/css">
+ body { font-family: Arial, sans; font-size: 0.8em}
+ </style>
+
+ <script src="../../lib/jquery/jquery-1.2.6.js"></script>
+ <script src="../../src/core/Core.js"></script>
+ <script src="../../src/core/QueryItem.js"></script>
+ <script src="../../src/core/Manager.js"></script>
+ <script src="../../src/core/AbstractWidget.js"></script>
+ <script src="../../src/core/AbstractServerSideWidget.js"></script>
+ <script src="../../src/core/AbstractClientSideWidget.js"></script>
+ <script src="../../src/serverside/SimpleServerSideWidget.js"/></script>
+ <script src="../../src/serverside/FacetServerSideWidget.js"/></script>
+
+ <script>
+ var $sj = jQuery.noConflict();
+ </script>
+
+
+ <script>
+ var solrjsManager;
+ $sj(document).ready(function(){
+ solrjsManager = new
$sj.solrjs.Manager({solrUrl:"http://localhost:8983/solr/select"});
+
+ // a custom result widget
+ var resultWidget = new $sj.solrjs.SimpleServerSideWidget({
+ id:"result",
+ target:"#result",
+ rows:5,
+ templateName:"testresult"
+ });
+
+ solrjsManager.addWidget(resultWidget);
+ solrjsManager.addWidget(new $sj.solrjs.FacetServerSideWidget({id:"cat",
target:"#cat", fieldName:"cat"}));
+ solrjsManager.doRequestAll();
+ });
+ </script>
+ </head>
+
+<body>
+ <body>
+ <div id="facets" style="float:left;width:300px;">
+ <h3 style="margin-top:0px">cat</h3>
+ <div id="cat"></div>
+ </div>
+ <div id="result" style="margin-left:300px;"></div>
+</body>
+</body>
+</html>
Added:
lucene/solr/trunk/contrib/javascript/example/reuters/importer/java/org/apache/solr/solrjs/ReutersService.java
URL:
http://svn.apache.org/viewvc/lucene/solr/trunk/contrib/javascript/example/reuters/importer/java/org/apache/solr/solrjs/ReutersService.java?rev=726901&view=auto
==============================================================================
---
lucene/solr/trunk/contrib/javascript/example/reuters/importer/java/org/apache/solr/solrjs/ReutersService.java
(added)
+++
lucene/solr/trunk/contrib/javascript/example/reuters/importer/java/org/apache/solr/solrjs/ReutersService.java
Mon Dec 15 17:03:00 2008
@@ -0,0 +1,251 @@
+package org.apache.solr.solrjs;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
+import org.apache.solr.common.SolrInputDocument;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+public class ReutersService {
+
+ private Map<String, String> countryCodesMap = new HashMap<String,
String>();
+
+ public static void main(String[] args) throws XPathExpressionException,
IOException, ParserConfigurationException, SAXException, SolrServerException,
ParseException {
+ String usage = "Usage: java -jar reutersimporter.jar <solrUrl>
<datadir>";
+
+ URL solrUrl = null;
+ try {
+ solrUrl = new URL(args[0]);
+ } catch (Exception e) {
+ System.out.println("First argument needs to be an
URL!");
+ System.out.println(usage);
+ }
+ File baseDir = null;
+ try {
+ baseDir = new File(args[1]);
+ if (!baseDir.exists() || !baseDir.isDirectory()) {
+ System.out.println("Second argument needs to be
an existing directory!");;
+ System.out.println(usage);
+ }
+ } catch (Exception e) {
+ System.out.println("Second argument needs to be an
existing directory!");;
+ System.out.println(usage);
+ }
+
+ if (solrUrl != null && baseDir!= null && baseDir.exists() &&
baseDir.isDirectory()) {
+ ReutersService reutersService = new
ReutersService(solrUrl.toExternalForm());
+ reutersService.readDirectory(baseDir);
+ }
+ }
+
+ /**
+ * The Solr Server to use
+ */
+ private SolrServer solrServer;
+
+ /**
+ * A shared xpath instance
+ */
+ private final XPath xPath = XPathFactory.newInstance().newXPath();
+
+ /**
+ * The format used in the sgml files.
+ * eg. 26-FEB-1987 15:01:01.79
+ */
+ private final SimpleDateFormat reutersDateFormat = new
SimpleDateFormat("dd-MMM-yyyy kk:mm:ss.SS", Locale.ENGLISH);
+
+ /**
+ * A service that inputs the reuters TODO dataset.
+ * @param solrUrl The url of the solr server.
+ */
+ public ReutersService(String solrUrl) {
+ try {
+ this.solrServer = new CommonsHttpSolrServer(solrUrl);
+ this.solrServer.ping();
+ } catch (Exception e) {
+ throw new RuntimeException("unable to connect to solr
server: " + solrUrl, e );
+ }
+ }
+
+ /**
+ * Takes a <REUTERS> node and converts it into a SolrInoutDocument.
+ * @param element A <REUTERS> node.
+ * @throws XPathExpressionException
+ * @throws SolrServerException
+ * @throws IOException
+ * @throws ParseException
+ */
+ public void readDocument(Element element) throws
XPathExpressionException, SolrServerException, IOException, ParseException {
+
+ SolrInputDocument inputDocument = new SolrInputDocument();
+ inputDocument.addField("id", element.getAttribute("NEWID"));
+ inputDocument.addField("title", xPath.evaluate("TEXT/TITLE",
element));
+ inputDocument.addField("dateline",
xPath.evaluate("TEXT/DATELINE", element).trim());
+ inputDocument.addField("text", xPath.evaluate("TEXT/BODY",
element).trim());
+ inputDocument.addField("places", readList("PLACES/D", element));
+ inputDocument.addField("topics", readList("TOPICS/D", element));
+ inputDocument.addField("organisations", readList("ORGS/D",
element));
+ inputDocument.addField("exchanges", readList("EXCHANGES/D",
element));
+ inputDocument.addField("companies", readList("COMPANIES/D",
element));
+ try {
+ inputDocument.addField("date",
this.reutersDateFormat.parse(xPath.evaluate("DATE", element)));
+ } catch (ParseException e) {
+ inputDocument.addField("date",
this.reutersDateFormat.parse("0" + xPath.evaluate("DATE", element)));
+ }
+
+ for (Object place : inputDocument.getFieldValues("places")) {
+ String code = this.countryCodesMap.get(place);
+ if (code == null) {
+ try {
+ code = getCodeForPlace((String) place);
+ this.countryCodesMap.put((String)
place, code);
+ } catch (SAXException e) {
+ e.printStackTrace();
+ } catch (ParserConfigurationException e) {
+ e.printStackTrace();
+ }
+ }
+ inputDocument.addField("countryCodes", code);
+ }
+
+ this.solrServer.add(inputDocument);
+ System.out.println(inputDocument.getField("title"));
+ }
+
+ private String getCodeForPlace(String place) throws
MalformedURLException, SAXException, IOException, ParserConfigurationException,
XPathExpressionException {
+ DocumentBuilderFactory dbfac =
DocumentBuilderFactory.newInstance();
+ DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
+ Document doc = docBuilder.parse(new
URL("http://ws.geonames.org/search?q=" + place).openStream());
+ return xPath.evaluate("/geonames/geoname/countryCode", doc);
+ }
+
+ /**
+ * Reads a whole .sgml file.
+ * @param file The sgml reuters file.
+ * @throws XPathExpressionException
+ * @throws IOException
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws SolrServerException
+ * @throws ParseException
+ */
+ public void readFile(File file) throws XPathExpressionException,
IOException, ParserConfigurationException, SAXException, SolrServerException,
ParseException {
+ String documentString = readFileAsString(file);
+
+ // remove "bad" entities
+ documentString = documentString.replaceAll("&#\\d;", "");
+ documentString = documentString.replaceAll("&#\\d\\d;", "");
+
+ // remove doctype declaration
+ documentString = documentString.replaceAll("<!DOCTYPE lewis
SYSTEM \"lewis.dtd\">", "");
+
+ // add a document root
+ documentString = "<root>" + documentString + "</root>";
+
+ DocumentBuilderFactory dbfac =
DocumentBuilderFactory.newInstance();
+ DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
+ Document doc = docBuilder.parse(new
ByteArrayInputStream(documentString.getBytes()));
+
+ NodeList nodeList = (NodeList) xPath.evaluate("/root/REUTERS",
doc, XPathConstants.NODESET);
+ System.out.println("READING FILE: " + file.getAbsoluteFile());
+ for (int i=0; i< nodeList.getLength(); i++) {
+ System.out.print(" - " + file.getName() + "(" + i + ")
");
+ readDocument((Element) nodeList.item(i));
+ }
+
+ this.solrServer.commit();
+
+ }
+
+ /**
+ * Reads a whole directory containing reuters .sgml files-
+ * @param directory
+ * @throws XPathExpressionException
+ * @throws IOException
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws SolrServerException
+ * @throws ParseException
+ */
+ public void readDirectory(File directory) throws XPathExpressionException,
IOException, ParserConfigurationException, SAXException, SolrServerException,
ParseException {
+ File[] files = directory.listFiles(new FileFilter() {
+ public boolean accept(File pathname) {
+ if (pathname.getName().contains(".sgm")) {
+ return true;
+ }
+ return false;
+ }
+ });
+ if (files.length == 0) {
+ throw new RuntimeException("Directory doesn't contain sgml
files!");
+ }
+ for (int i = 0; i < files.length; i++) {
+ File file = files[i];
+ readFile(file);
+ }
+ }
+
+ /**
+ * Helper that converts a listnode into a java list.
+ * @param path
+ * @param element
+ * @return
+ * @throws XPathExpressionException
+ */
+ private List<String> readList(String path, Element element) throws
XPathExpressionException {
+ List<String> list = new ArrayList<String>();
+ NodeList nodeList = (NodeList) xPath.evaluate(path, element,
XPathConstants.NODESET);
+ for (int i=0; i< nodeList.getLength(); i++) {
+ list.add(nodeList.item(i).getTextContent());
+ }
+ return list;
+ }
+
+ /**
+ * Helper that reads a file into a string.
+ * @param file
+ * @return
+ * @throws java.io.IOException
+ */
+ private static String readFileAsString(File file) throws
java.io.IOException {
+ StringBuffer fileData = new StringBuffer(1000);
+ BufferedReader reader = new BufferedReader(new FileReader(file));
+ char[] buf = new char[1024];
+ int numRead=0;
+ while((numRead=reader.read(buf)) != -1){
+ String readData = String.valueOf(buf, 0, numRead);
+ fileData.append(readData);
+ buf = new char[1024];
+ }
+ reader.close();
+ return fileData.toString();
+ }
+
+}
Added:
lucene/solr/trunk/contrib/javascript/example/reuters/testdata/download-dataset.sh
URL:
http://svn.apache.org/viewvc/lucene/solr/trunk/contrib/javascript/example/reuters/testdata/download-dataset.sh?rev=726901&view=auto
==============================================================================
---
lucene/solr/trunk/contrib/javascript/example/reuters/testdata/download-dataset.sh
(added)
+++
lucene/solr/trunk/contrib/javascript/example/reuters/testdata/download-dataset.sh
Mon Dec 15 17:03:00 2008
@@ -0,0 +1,4 @@
+wget http://kdd.ics.uci.edu/databases/reuters21578/reuters21578.tar.gz
+tar xvf reuters21578.tar.gz
+wget http://kdd.ics.uci.edu/databases/reuters21578/reuters21578.tar.gz
+tar xvf reuters21578.tar.gz
Propchange:
lucene/solr/trunk/contrib/javascript/example/reuters/testdata/download-dataset.sh
------------------------------------------------------------------------------
svn:executable = *