You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by si...@apache.org on 2011/03/30 11:17:42 UTC
svn commit: r1086876 [15/18] - in /lucene/dev/branches/realtime_search: ./
dev-tools/eclipse/ dev-tools/idea/ dev-tools/idea/.idea/libraries/
dev-tools/idea/lucene/ dev-tools/idea/solr/
dev-tools/idea/solr/contrib/analysis-extras/ dev-tools/idea/solr/c...
Modified: lucene/dev/branches/realtime_search/solr/example/solr/conf/velocity/VM_global_library.vm
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/example/solr/conf/velocity/VM_global_library.vm?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/example/solr/conf/velocity/VM_global_library.vm (original)
+++ lucene/dev/branches/realtime_search/solr/example/solr/conf/velocity/VM_global_library.vm Wed Mar 30 09:17:25 2011
@@ -113,14 +113,14 @@
<span class="facet-field">$display</span>
<ul>
#if($before && $before != "")
- #set($value = '[* TO "' + $start + '"]')
+ #set($value = "[* TO " + $start + "]")
#set($facetURL = "#url_for_facet_range_filter($fieldName, $value)")
<li><a href="$facetURL">Less than $start</a> ($before)</li>
#end
#foreach ($facet in $field)
#set($rangeEnd = $math.add($facet.key, $gap))
- #set($value = "[" + $facet.key + " TO $rangeEnd]")
- #set($facetURL = "#url_for_facet_filter($fieldName, $value)")
+ #set($value = "[" + $facet.key + " TO " + $rangeEnd + "]")
+ #set($facetURL = "#url_for_facet_range_filter($fieldName, $value)")
#if ($facetURL != '')
<li><a href="$facetURL">$facet.key</a> ($facet.value)</li>
#end
Modified: lucene/dev/branches/realtime_search/solr/example/solr/conf/xslt/example.xsl
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/example/solr/conf/xslt/example.xsl?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/example/solr/conf/xslt/example.xsl (original)
+++ lucene/dev/branches/realtime_search/solr/example/solr/conf/xslt/example.xsl Wed Mar 30 09:17:25 2011
@@ -24,7 +24,7 @@
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
>
- <xsl:output media-type="text/html; charset=UTF-8" encoding="UTF-8"/>
+ <xsl:output media-type="text/html" encoding="UTF-8"/>
<xsl:variable name="title" select="concat('Solr search results (',response/result/@numFound,' documents)')"/>
Modified: lucene/dev/branches/realtime_search/solr/example/solr/conf/xslt/example_atom.xsl
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/example/solr/conf/xslt/example_atom.xsl?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/example/solr/conf/xslt/example_atom.xsl (original)
+++ lucene/dev/branches/realtime_search/solr/example/solr/conf/xslt/example_atom.xsl Wed Mar 30 09:17:25 2011
@@ -27,7 +27,7 @@
<xsl:output
method="xml"
encoding="utf-8"
- media-type="text/xml; charset=UTF-8"
+ media-type="application/xml"
/>
<xsl:template match='/'>
Modified: lucene/dev/branches/realtime_search/solr/example/solr/conf/xslt/example_rss.xsl
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/example/solr/conf/xslt/example_rss.xsl?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/example/solr/conf/xslt/example_rss.xsl (original)
+++ lucene/dev/branches/realtime_search/solr/example/solr/conf/xslt/example_rss.xsl Wed Mar 30 09:17:25 2011
@@ -27,7 +27,7 @@
<xsl:output
method="xml"
encoding="utf-8"
- media-type="text/xml; charset=UTF-8"
+ media-type="application/xml"
/>
<xsl:template match='/'>
<rss version="2.0">
Modified: lucene/dev/branches/realtime_search/solr/example/solr/conf/xslt/luke.xsl
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/example/solr/conf/xslt/luke.xsl?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/example/solr/conf/xslt/luke.xsl (original)
+++ lucene/dev/branches/realtime_search/solr/example/solr/conf/xslt/luke.xsl Wed Mar 30 09:17:25 2011
@@ -28,7 +28,7 @@
<xsl:output
method="html"
encoding="UTF-8"
- media-type="text/html; charset=UTF-8"
+ media-type="text/html"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
/>
Modified: lucene/dev/branches/realtime_search/solr/lib/README.committers.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/lib/README.committers.txt?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/lib/README.committers.txt (original)
+++ lucene/dev/branches/realtime_search/solr/lib/README.committers.txt Wed Mar 30 09:17:25 2011
@@ -21,6 +21,14 @@ based on changes in the terms of the dep
---
+When adding a jar or updating an existing jar, be sure to include/update
+xyz-LICENSE.txt and if applicable, xyz-NOTICE.txt. These files often
+change across versions of the dependency, so when updating be SURE to
+update them to the recent version. This also allows others to see
+what changed with respect to licensing in the commit diff.
+
+---
+
Any changes made to this directory should be noted in CHANGES.txt,
along with the specific version information. If the version is a
"snapshot" of another Apache project, include the SVN revision number.
Modified: lucene/dev/branches/realtime_search/solr/lib/apache-solr-noggit-pom.xml.template
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/lib/apache-solr-noggit-pom.xml.template?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/lib/apache-solr-noggit-pom.xml.template (original)
+++ lucene/dev/branches/realtime_search/solr/lib/apache-solr-noggit-pom.xml.template Wed Mar 30 09:17:25 2011
@@ -31,6 +31,6 @@
<artifactId>solr-noggit</artifactId>
<name>Solr Specific Noggit</name>
<version>@version@</version>
- <description>Solr Specific Noggit</description>
+ <description>Solr Specific Noggit r944541</description>
<packaging>jar</packaging>
</project>
Modified: lucene/dev/branches/realtime_search/solr/lib/solr-commons-csv-pom.xml.template
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/lib/solr-commons-csv-pom.xml.template?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/lib/solr-commons-csv-pom.xml.template (original)
+++ lucene/dev/branches/realtime_search/solr/lib/solr-commons-csv-pom.xml.template Wed Mar 30 09:17:25 2011
@@ -31,6 +31,6 @@
<artifactId>solr-commons-csv</artifactId>
<name>Solr Specific Commons CSV</name>
<version>@version@</version>
- <description>Solr Specific Commons CSV</description>
+ <description>Solr Specific Commons CSV v1.0-SNAPSHOT-r966014</description>
<packaging>jar</packaging>
</project>
Modified: lucene/dev/branches/realtime_search/solr/site/features.html
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/site/features.html?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/site/features.html (original)
+++ lucene/dev/branches/realtime_search/solr/site/features.html Wed Mar 30 09:17:25 2011
@@ -253,7 +253,7 @@ document.write("Last Published: " + docu
<h2 class="boxed">Solr in a Nutshell</h2>
<div class="section">
<p>
- Solr is a standalone enterprise search server with a web-services like API. You put documents in it (called "indexing") via XML over HTTP. You query it via HTTP GET and receive XML results.
+ Solr is a standalone enterprise search server with a REST-like API. You put documents in it (called "indexing") via XML, JSON or binary over HTTP. You query it via HTTP GET and receive XML, JSON, or binary results.
</p>
<ul>
@@ -288,6 +288,8 @@ document.write("Last Published: " + docu
<li> Faceted Search and Filtering </li>
+<li> Geospatial Search </li>
+
<li> Advanced, Configurable Text Analysis </li>
<li> Highly Configurable and User Extensible Caching </li>
@@ -304,22 +306,24 @@ document.write("Last Published: " + docu
<li> Highly Scalable Distributed search with sharded index across multiple hosts </li>
-<li> XML, CSV/delimited-text, and binary update formats </li>
+<li> JSON, XML, CSV/delimited-text, and binary update formats </li>
<li> Easy ways to pull in data from databases and XML files from local disk and HTTP sources </li>
<li> Rich Document Parsing and Indexing (PDF, Word, HTML, etc) using Apache Tika </li>
+<li> Apache UIMA integration for configurable metadata extraction </li>
+
<li> Multiple search indices </li>
</ul>
</div>
-<a name="N10069"></a><a name="Detailed+Features"></a>
+<a name="N1006F"></a><a name="Detailed+Features"></a>
<h2 class="boxed">Detailed Features</h2>
<div class="section">
-<a name="N1006F"></a><a name="Schema"></a>
+<a name="N10075"></a><a name="Schema"></a>
<h3 class="boxed">Schema</h3>
<ul>
@@ -340,19 +344,19 @@ document.write("Last Published: " + docu
<li>Many additional text analysis components including word splitting, regex and sounds-like filters</li>
</ul>
-<a name="N10090"></a><a name="Query"></a>
+<a name="N10096"></a><a name="Query"></a>
<h3 class="boxed">Query</h3>
<ul>
<li>HTTP interface with configurable response formats (XML/XSLT, JSON, Python, Ruby, PHP, Velocity, binary)</li>
-<li>Sort by any number of fields</li>
+<li>Sort by any number of fields, and by complex functions of numeric fields</li>
<li>Advanced DisMax query parser for high relevancy results from user-entered queries</li>
<li>Highlighted context snippets</li>
-<li>Faceted Searching based on unique field values, explicit queries, or date ranges</li>
+<li>Faceted Searching based on unique field values, explicit queries, date ranges, and numeric ranges</li>
<li>Multi-Select Faceting by tagging and selectively excluding filters</li>
@@ -373,14 +377,14 @@ document.write("Last Published: " + docu
<li>Combine queries derived from different syntaxes</li>
-<li>Auto-suggest functionality</li>
+<li>Auto-suggest functionality for completing user queries</li>
<li>Allow configuration of top results for a query, overriding normal scoring and sorting</li>
<li>Performance Optimizations</li>
</ul>
-<a name="N100CC"></a><a name="Core"></a>
+<a name="N100D2"></a><a name="Core"></a>
<h3 class="boxed">Core</h3>
<ul>
@@ -405,7 +409,7 @@ document.write("Last Published: " + docu
<li>"Luke" request handler for corpus information</li>
</ul>
-<a name="N100F3"></a><a name="Caching"></a>
+<a name="N100F9"></a><a name="Caching"></a>
<h3 class="boxed">Caching</h3>
<ul>
@@ -439,7 +443,7 @@ document.write("Last Published: " + docu
<li>User level caching with autowarming support</li>
</ul>
-<a name="N10118"></a><a name="Replication"></a>
+<a name="N1011E"></a><a name="Replication"></a>
<h3 class="boxed">Replication</h3>
<ul>
@@ -452,7 +456,7 @@ document.write("Last Published: " + docu
<li>Replication and automatic reloading of configuration files</li>
</ul>
-<a name="N1012D"></a><a name="Admin+Interface"></a>
+<a name="N10133"></a><a name="Admin+Interface"></a>
<h3 class="boxed">Admin Interface</h3>
<ul>
Modified: lucene/dev/branches/realtime_search/solr/site/features.pdf
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/site/features.pdf?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
Binary files - no diff available.
Modified: lucene/dev/branches/realtime_search/solr/site/index.html
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/site/index.html?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/site/index.html (original)
+++ lucene/dev/branches/realtime_search/solr/site/index.html Wed Mar 30 09:17:25 2011
@@ -294,8 +294,8 @@ document.write("Last Published: " + docu
Solr is the popular, blazing fast open source enterprise search
platform from the Apache Lucene project. Its major features include
powerful full-text search, hit highlighting, faceted search, dynamic
-clustering, database integration, and rich document (e.g., Word, PDF)
-handling. Solr is highly scalable, providing distributed search and
+clustering, database integration, rich document (e.g., Word, PDF)
+handling, and geospatial search. Solr is highly scalable, providing distributed search and
index replication, and it powers the search and navigation features of
many of the world's largest internet sites.
</p>
Modified: lucene/dev/branches/realtime_search/solr/site/index.pdf
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/site/index.pdf?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
Binary files - no diff available.
Modified: lucene/dev/branches/realtime_search/solr/site/tutorial.html
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/site/tutorial.html?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/site/tutorial.html (original)
+++ lucene/dev/branches/realtime_search/solr/site/tutorial.html Wed Mar 30 09:17:25 2011
@@ -5,7 +5,7 @@
<meta content="Apache Forrest" name="Generator">
<meta name="Forrest-version" content="0.8">
<meta name="Forrest-skin-name" content="lucene">
-<title>Solr tutorial (version 4.0.0.2011.01.04.00.08.44)</title>
+<title>Solr tutorial</title>
<link type="text/css" href="skin/basic.css" rel="stylesheet">
<link media="screen" type="text/css" href="skin/screen.css" rel="stylesheet">
<link media="print" type="text/css" href="skin/print.css" rel="stylesheet">
@@ -192,10 +192,7 @@ document.write("Last Published: " + docu
}
}
</script>
-<div id="credit">
-<hr>
- This document is for Apache Solr version 4.0.0.2011.01.04.00.08.44. If you are using a different version of Solr, please consult the documentation that was distributed with the version you are using.
- </div>
+<div id="credit"></div>
<div id="roundbottom">
<img style="display: none" class="corner" height="15" width="15" alt="" src="skin/images/rc-b-l-15-1body-2menu-3menu.png"></div>
<!--+
@@ -217,9 +214,6 @@ document.write("Last Published: " + docu
PDF</a>
</div>
<h1>Solr tutorial</h1>
-<div id="motd-area">
- This document is for Apache Solr version 4.0.0.2011.01.04.00.08.44. If you are using a different version of Solr, please consult the documentation that was distributed with the version you are using.
- </div>
<div id="minitoc-area">
<ul class="minitoc">
<li>
@@ -257,6 +251,9 @@ document.write("Last Published: " + docu
<a href="#Faceted+Search">Faceted Search</a>
</li>
<li>
+<a href="#Search+UI">Search UI</a>
+</li>
+<li>
<a href="#Text+Analysis">Text Analysis</a>
<ul class="minitoc">
<li>
@@ -290,10 +287,9 @@ To follow along with this tutorial, you
<ol>
<li>Java 1.6 or greater. Some places you can get it are from
- <a href="http://java.sun.com/j2se/downloads.html">OpenJDK</a>,
- <a href="http://java.sun.com/j2se/downloads.html">Sun</a>,
+ <a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html">Oracle</a>,
+ <a href="http://openjdk.java.net/">Open JDK</a>,
<a href="http://www.ibm.com/developerworks/java/jdk/">IBM</a>, or
- <a href="http://www.oracle.com/technology/products/jrockit/index.html">Oracle</a>.
<br>
Running <span class="codefrag">java -version</span> at the command line should indicate a version
number starting with 1.6. Gnu's GCJ is not supported and does not work with Solr.
@@ -306,7 +302,7 @@ To follow along with this tutorial, you
</div>
-<a name="N10043"></a><a name="Getting+Started"></a>
+<a name="N1003F"></a><a name="Getting+Started"></a>
<h2 class="boxed">Getting Started</h2>
<div class="section">
<p>
@@ -335,7 +331,7 @@ To launch Jetty with the Solr WAR, and t
<pre class="code">
user:~/solr/example$ <strong>java -jar start.jar</strong>
2009-10-23 16:42:53.816::INFO: Logging to STDERR via org.mortbay.log.StdErrLog
-2009-10-23 16:42:53.907::INFO: jetty-6.1.3
+2009-10-23 16:42:53.907::INFO: jetty-6.1.26
...
@@ -354,7 +350,7 @@ You can see that the Solr is running by
-<a name="N1007B"></a><a name="Indexing+Data"></a>
+<a name="N10077"></a><a name="Indexing+Data"></a>
<h2 class="boxed">Indexing Data</h2>
<div class="section">
<p>
@@ -389,11 +385,11 @@ Clicking the "Search" button should take
</p>
<p>
-<a href="http://localhost:8983/solr/select/?q=solr&version=2.2&start=0&rows=10&indent=on">http://localhost:8983/solr/select/?q=solr&version=2.2&start=0&rows=10&indent=on</a>
+<a href="http://localhost:8983/solr/select/?q=solr&start=0&rows=10&indent=on">http://localhost:8983/solr/select/?q=solr&start=0&rows=10&indent=on</a>
</p>
<p>
-You can index all of the sample data, using the following command (assuming your shell supports the *.xml notation):
+You can index all of the sample data, using the following command (assuming your command line shell supports the *.xml notation):
</p>
<pre class="code">
user:~/solr/example/exampledocs$ <strong>java -jar post.jar *.xml</strong>
@@ -448,6 +444,11 @@ SimplePostTool: COMMITting Solr index ch
including those exported by Excel or MySQL.
</li>
+<li>
+<a href="http://wiki.apache.org/solr/UpdateJSON">POST JSON documents</a>
+
+</li>
+
<li>Index binary documents such as Word and PDF with
<a href="http://wiki.apache.org/solr/ExtractingRequestHandler">Solr Cell</a> (ExtractingRequestHandler).
</li>
@@ -464,7 +465,7 @@ SimplePostTool: COMMITting Solr index ch
-<a name="N100EB"></a><a name="Updating+Data"></a>
+<a name="N100ED"></a><a name="Updating+Data"></a>
<h2 class="boxed">Updating Data</h2>
<div class="section">
<p>
@@ -496,7 +497,7 @@ Go ahead and edit the existing XML files
the <span class="codefrag">java -jar post.jar</span> command, you'll see your changes reflected
in subsequent searches.
</p>
-<a name="N10119"></a><a name="Deleting+Data"></a>
+<a name="N1011B"></a><a name="Deleting+Data"></a>
<h3 class="boxed">Deleting Data</h3>
<p>You can delete data by POSTing a delete command to the update URL and specifying the value
of the document's unique key field, or a query that matches multiple documents (be careful with that one!). Since these commands
@@ -525,7 +526,7 @@ in subsequent searches.
</div>
-<a name="N1015F"></a><a name="Querying+Data"></a>
+<a name="N10161"></a><a name="Querying+Data"></a>
<h2 class="boxed">Querying Data</h2>
<div class="section">
<p>
@@ -556,7 +557,7 @@ in subsequent searches.
Solr provides a <a href="http://localhost:8983/solr/admin/form.jsp">query form</a> within the web admin interface
that allows setting the various request parameters and is useful when trying out or debugging queries.
</p>
-<a name="N10194"></a><a name="Sorting"></a>
+<a name="N10196"></a><a name="Sorting"></a>
<h3 class="boxed">Sorting</h3>
<p>
Solr provides a simple method to sort on one or more indexed fields.
@@ -592,13 +593,23 @@ in subsequent searches.
</ul>
<p>
+ Complex functions may also be used to sort results...
+ </p>
+<ul>
+
+<li>
+<a href="http://localhost:8983/solr/select/?indent=on&q=*:*&sort=div(popularity,add(price,1))+desc">q=video&sort=div(popularity,add(price,1)) desc</a>
+</li>
+
+</ul>
+<p>
If no sort is specified, the default is <span class="codefrag">score desc</span> to return the matches having the highest relevancy.
</p>
</div>
-<a name="N101C7"></a><a name="Highlighting"></a>
+<a name="N101D4"></a><a name="Highlighting"></a>
<h2 class="boxed">Highlighting</h2>
<div class="section">
<p>
@@ -625,7 +636,7 @@ in subsequent searches.
-<a name="N101F0"></a><a name="Faceted+Search"></a>
+<a name="N101FD"></a><a name="Faceted+Search"></a>
<h2 class="boxed">Faceted Search</h2>
<div class="section">
<p>
@@ -684,7 +695,25 @@ in subsequent searches.
-<a name="N10241"></a><a name="Text+Analysis"></a>
+<a name="N1024E"></a><a name="Search+UI"></a>
+<h2 class="boxed">Search UI</h2>
+<div class="section">
+<p>
+ Solr includes an example search interface built with velocity templating
+ that demonstrates many features, including searching, faceting, highlighting,
+ autocomplete, and geospatial searching.
+ </p>
+<p>
+ Try it out at
+ <a href="http://localhost:8983/solr/browse">http://localhost:8983/solr/browse</a>
+
+</p>
+</div> <!-- Search UI -->
+
+
+
+
+<a name="N10261"></a><a name="Text+Analysis"></a>
<h2 class="boxed">Text Analysis</h2>
<div class="section">
<p>
@@ -726,7 +755,7 @@ in subsequent searches.
<p>A full description of the analysis components, Analyzers, Tokenizers, and TokenFilters
available for use is <a href="http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters">here</a>.
</p>
-<a name="N10291"></a><a name="Analysis+Debugging"></a>
+<a name="N102B1"></a><a name="Analysis+Debugging"></a>
<h3 class="boxed">Analysis Debugging</h3>
<p>There is a handy <a href="http://localhost:8983/solr/admin/analysis.jsp">analysis</a>
debugging page where you can see how a text value is broken down into words,
@@ -755,7 +784,7 @@ in subsequent searches.
</div>
-<a name="N102D0"></a><a name="Conclusion"></a>
+<a name="N102F0"></a><a name="Conclusion"></a>
<h2 class="boxed">Conclusion</h2>
<div class="section">
<p>
Modified: lucene/dev/branches/realtime_search/solr/site/tutorial.pdf
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/site/tutorial.pdf?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
Binary files - no diff available.
Modified: lucene/dev/branches/realtime_search/solr/src/common/org/apache/solr/common/SolrDocument.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/common/org/apache/solr/common/SolrDocument.java?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/common/org/apache/solr/common/SolrDocument.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/common/org/apache/solr/common/SolrDocument.java Wed Mar 30 09:17:25 2011
@@ -26,6 +26,8 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
+import org.apache.solr.common.util.NamedList;
+
/**
* A concrete representation of a document within a Solr index. Unlike a lucene
@@ -88,6 +90,9 @@ public class SolrDocument implements Map
else if( value instanceof Collection ) {
// nothing
}
+ else if( value instanceof NamedList ) {
+ // nothing
+ }
else if( value instanceof Iterable ) {
ArrayList<Object> lst = new ArrayList<Object>();
for( Object o : (Iterable)value ) {
Modified: lucene/dev/branches/realtime_search/solr/src/common/org/apache/solr/common/params/FacetParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/common/org/apache/solr/common/params/FacetParams.java?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/common/org/apache/solr/common/params/FacetParams.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/common/org/apache/solr/common/params/FacetParams.java Wed Mar 30 09:17:25 2011
@@ -180,12 +180,13 @@ public interface FacetParams {
* exclusive of their end points.
* </p>
* <p>
- * The default value if none are specified is: [lower,upper,edge]
+ * The default value if none are specified is: [lower,upper,edge] <i>(NOTE: This is different then FACET_RANGE_INCLUDE)</i>
* </p>
* <p>
* Can be overriden on a per field basis.
* </p>
* @see FacetRangeInclude
+ * @see #FACET_RANGE_INCLUDE
*/
public static final String FACET_DATE_INCLUDE = FACET_DATE + ".include";
@@ -230,13 +231,6 @@ public interface FacetParams {
* Can be overriden on a per field basis.
*/
public static final String FACET_RANGE_OTHER = FACET_RANGE + ".other";
- /**
- * String indicating whether ranges for numerical range faceting
- * should be exclusive or inclusive. By default both the start and
- * end point are inclusive.
- * Can be overriden on a per field basis.
- * @see FacetNumberExclusive
- */
/**
* <p>
@@ -245,7 +239,7 @@ public interface FacetParams {
* exclusive of their end points.
* </p>
* <p>
- * The default value if none are specified is: [lower,upper,edge]
+ * The default value if none are specified is: lower
* </p>
* <p>
* Can be overriden on a per field basis.
@@ -335,15 +329,16 @@ public interface FacetParams {
}
/**
* Convinience method for parsing the param value according to the
- * correct semantics.
+ * correct semantics and applying the default of "LOWER"
*/
public static EnumSet<FacetRangeInclude> parseParam(final String[] param) {
// short circut for default behavior
if (null == param || 0 == param.length )
- return EnumSet.of(LOWER, UPPER, EDGE);
+ return EnumSet.of(LOWER);
// build up set containing whatever is specified
- final EnumSet<FacetRangeInclude> include = EnumSet.noneOf(FacetRangeInclude.class);
+ final EnumSet<FacetRangeInclude> include
+ = EnumSet.noneOf(FacetRangeInclude.class);
for (final String o : param) {
include.add(FacetRangeInclude.get(o));
}
Modified: lucene/dev/branches/realtime_search/solr/src/common/org/apache/solr/common/util/ConcurrentLRUCache.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/common/org/apache/solr/common/util/ConcurrentLRUCache.java?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/common/org/apache/solr/common/util/ConcurrentLRUCache.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/common/org/apache/solr/common/util/ConcurrentLRUCache.java Wed Mar 30 09:17:25 2011
@@ -354,13 +354,17 @@ public class ConcurrentLRUCache<K,V> {
private static class PQueue<K,V> extends PriorityQueue<CacheEntry<K,V>> {
int myMaxSize;
+ final Object[] heap;
+
PQueue(int maxSz) {
- super.initialize(maxSz);
+ super(maxSz);
+ heap = getHeapArray();
myMaxSize = maxSz;
}
+ @SuppressWarnings("unchecked")
Iterable<CacheEntry<K,V>> getValues() {
- return Collections.unmodifiableCollection(Arrays.asList(heap));
+ return (Iterable) Collections.unmodifiableCollection(Arrays.asList(heap));
}
@Override
@@ -370,12 +374,13 @@ public class ConcurrentLRUCache<K,V> {
}
// necessary because maxSize is private in base class
+ @SuppressWarnings("unchecked")
public CacheEntry<K,V> myInsertWithOverflow(CacheEntry<K,V> element) {
if (size() < myMaxSize) {
add(element);
return null;
- } else if (size() > 0 && !lessThan(element, heap[1])) {
- CacheEntry<K,V> ret = heap[1];
+ } else if (size() > 0 && !lessThan(element, (CacheEntry<K,V>) heap[1])) {
+ CacheEntry<K,V> ret = (CacheEntry<K,V>) heap[1];
heap[1] = element;
updateTop();
return ret;
Modified: lucene/dev/branches/realtime_search/solr/src/common/org/apache/solr/common/util/FileUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/common/org/apache/solr/common/util/FileUtils.java?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/common/org/apache/solr/common/util/FileUtils.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/common/org/apache/solr/common/util/FileUtils.java Wed Mar 30 09:17:25 2011
@@ -54,9 +54,7 @@ public class FileUtils {
}
/**
- * Copied from Lucene's {@link org.apache.lucene.store.FSDirectory#sync(String)}
- *
- * @see org.apache.lucene.store.FSDirectory#sync(String)
+ * Copied from Lucene's FSDirectory.sync(String) <!-- protected -->
*
* @param fullFile the File to be synced to disk
* @throws IOException if the file could not be synced
Modified: lucene/dev/branches/realtime_search/solr/src/common/org/apache/solr/common/util/JavaBinCodec.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/common/org/apache/solr/common/util/JavaBinCodec.java?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/common/org/apache/solr/common/util/JavaBinCodec.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/common/org/apache/solr/common/util/JavaBinCodec.java Wed Mar 30 09:17:25 2011
@@ -295,27 +295,13 @@ public class JavaBinCodec {
}
public void writeSolrDocument(SolrDocument doc) throws IOException {
- writeSolrDocument(doc, null);
- }
-
- public void writeSolrDocument(SolrDocument doc, Set<String> fields) throws IOException {
- int count = 0;
- if (fields == null) {
- count = doc.getFieldNames().size();
- } else {
- for (Map.Entry<String, Object> entry : doc) {
- if (fields.contains(entry.getKey())) count++;
- }
- }
writeTag(SOLRDOC);
- writeTag(ORDERED_MAP, count);
+ writeTag(ORDERED_MAP, doc.size());
for (Map.Entry<String, Object> entry : doc) {
- if (fields == null || fields.contains(entry.getKey())) {
- String name = entry.getKey();
- writeExternString(name);
- Object val = entry.getValue();
- writeVal(val);
- }
+ String name = entry.getKey();
+ writeExternString(name);
+ Object val = entry.getValue();
+ writeVal(val);
}
}
Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/core/Config.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/core/Config.java?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/core/Config.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/core/Config.java Wed Mar 30 09:17:25 2011
@@ -17,32 +17,40 @@
package org.apache.solr.core;
+import org.apache.lucene.util.Version;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.util.DOMUtil;
+import org.apache.solr.common.util.SystemIdResolver;
+import org.apache.solr.common.util.XMLErrorLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.util.DOMUtil;
+import org.apache.commons.io.IOUtils;
-import javax.xml.parsers.*;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathFactory;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
-import javax.xml.namespace.QName;
-import java.io.*;
+import javax.xml.xpath.XPathFactory;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.lucene.util.Version;
/**
* @version $Id$
*/
public class Config {
public static final Logger log = LoggerFactory.getLogger(Config.class);
+ private static final XMLErrorLogger xmllog = new XMLErrorLogger(log);
static final XPathFactory xpathFactory = XPathFactory.newInstance();
@@ -63,7 +71,7 @@ public class Config {
{
this( loader, name, null, null );
}
-
+
/**
* Builds a config:
* <p>
@@ -77,13 +85,13 @@ public class Config {
* </p>
* @param loader the resource loader used to obtain an input stream if 'is' is null
* @param name the resource name used if the input stream 'is' is null
- * @param is the resource as a stream
+ * @param is the resource as a SAX InputSource
* @param prefix an optional prefix that will be preprended to all non-absolute xpath expressions
* @throws javax.xml.parsers.ParserConfigurationException
* @throws java.io.IOException
* @throws org.xml.sax.SAXException
*/
- public Config(SolrResourceLoader loader, String name, InputStream is, String prefix) throws ParserConfigurationException, IOException, SAXException
+ public Config(SolrResourceLoader loader, String name, InputSource is, String prefix) throws ParserConfigurationException, IOException, SAXException
{
if( loader == null ) {
loader = new SolrResourceLoader( null );
@@ -91,21 +99,35 @@ public class Config {
this.loader = loader;
this.name = name;
this.prefix = (prefix != null && !prefix.endsWith("/"))? prefix + '/' : prefix;
- InputStream lis = is;
try {
- if (lis == null) {
- lis = loader.openConfig(name);
- }
javax.xml.parsers.DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+
+ if (is == null) {
+ is = new InputSource(loader.openConfig(name));
+ is.setSystemId(SystemIdResolver.createSystemIdFromResourceName(name));
+ }
+
+ // only enable xinclude, if a SystemId is available
+ if (is.getSystemId() != null) {
+ try {
+ dbf.setXIncludeAware(true);
+ dbf.setNamespaceAware(true);
+ } catch(UnsupportedOperationException e) {
+ log.warn(name + " XML parser doesn't support XInclude option");
+ }
+ }
+
+ final DocumentBuilder db = dbf.newDocumentBuilder();
+ db.setEntityResolver(new SystemIdResolver(loader));
+ db.setErrorHandler(xmllog);
try {
- dbf.setXIncludeAware(true);
- dbf.setNamespaceAware(true);
- } catch(UnsupportedOperationException e) {
- log.warn(name + " XML parser doesn't support XInclude option");
+ doc = db.parse(is);
+ } finally {
+ // some XML parsers are broken and don't close the byte stream (but they should according to spec)
+ IOUtils.closeQuietly(is.getByteStream());
}
- doc = dbf.newDocumentBuilder().parse(lis);
- DOMUtil.substituteProperties(doc, loader.getCoreProperties());
+ DOMUtil.substituteProperties(doc, loader.getCoreProperties());
} catch (ParserConfigurationException e) {
SolrException.log(log, "Exception during parsing file: " + name, e);
throw e;
@@ -115,9 +137,6 @@ public class Config {
} catch( SolrException e ){
SolrException.log(log,"Error in "+name,e);
throw e;
- } finally {
- // if this opens the resource, it also closes it
- if (lis != is) lis.close();
}
}
Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/core/CoreContainer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/core/CoreContainer.java?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/core/CoreContainer.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/core/CoreContainer.java Wed Mar 30 09:17:25 2011
@@ -42,6 +42,7 @@ import org.apache.solr.common.params.Cor
import org.apache.solr.common.util.DOMUtil;
import org.apache.solr.common.util.XML;
import org.apache.solr.common.util.FileUtils;
+import org.apache.solr.common.util.SystemIdResolver;
import org.apache.solr.handler.admin.CoreAdminHandler;
import org.apache.solr.schema.IndexSchema;
import org.apache.zookeeper.KeeperException;
@@ -49,6 +50,7 @@ import org.apache.commons.io.IOUtils;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
+import org.xml.sax.InputSource;
/**
@@ -237,7 +239,7 @@ public class CoreContainer
cores.load(solrHome, fconf);
} else {
log.info("no solr.xml file found - using default");
- cores.load(solrHome, new ByteArrayInputStream(DEF_SOLR_XML.getBytes("UTF-8")));
+ cores.load(solrHome, new InputSource(new ByteArrayInputStream(DEF_SOLR_XML.getBytes("UTF-8"))));
cores.configFile = fconf;
}
@@ -285,7 +287,7 @@ public class CoreContainer
*/
public void load(String dir, File configFile ) throws ParserConfigurationException, IOException, SAXException {
this.configFile = configFile;
- this.load(dir, new FileInputStream(configFile));
+ this.load(dir, new InputSource(configFile.toURI().toASCIIString()));
}
/**
@@ -297,125 +299,118 @@ public class CoreContainer
* @throws IOException
* @throws SAXException
*/
- public void load(String dir, InputStream cfgis)
+ public void load(String dir, InputSource cfgis)
throws ParserConfigurationException, IOException, SAXException {
this.loader = new SolrResourceLoader(dir);
solrHome = loader.getInstanceDir();
- try {
- Config cfg = new Config(loader, null, cfgis, null);
- String dcoreName = cfg.get("solr/cores/@defaultCoreName", null);
- if(dcoreName != null) {
- defaultCoreName = dcoreName;
- }
- persistent = cfg.getBool("solr/@persistent", false);
- libDir = cfg.get("solr/@sharedLib", null);
- zkHost = cfg.get("solr/@zkHost" , null);
- adminPath = cfg.get("solr/cores/@adminPath", null);
- shareSchema = cfg.getBool("solr/cores/@shareSchema", false);
- int zkClientTimeout = cfg.getInt("solr/cores/@zkClientTimeout", 10000);
-
- hostPort = System.getProperty("hostPort");
- if (hostPort == null) {
- hostPort = cfg.get("solr/cores/@hostPort", "8983");
- }
+ Config cfg = new Config(loader, null, cfgis, null);
+ String dcoreName = cfg.get("solr/cores/@defaultCoreName", null);
+ if(dcoreName != null) {
+ defaultCoreName = dcoreName;
+ }
+ persistent = cfg.getBool("solr/@persistent", false);
+ libDir = cfg.get("solr/@sharedLib", null);
+ zkHost = cfg.get("solr/@zkHost" , null);
+ adminPath = cfg.get("solr/cores/@adminPath", null);
+ shareSchema = cfg.getBool("solr/cores/@shareSchema", false);
+ int zkClientTimeout = cfg.getInt("solr/cores/@zkClientTimeout", 10000);
+
+ hostPort = System.getProperty("hostPort");
+ if (hostPort == null) {
+ hostPort = cfg.get("solr/cores/@hostPort", "8983");
+ }
- hostContext = cfg.get("solr/cores/@hostContext", "solr");
- host = cfg.get("solr/cores/@host", null);
+ hostContext = cfg.get("solr/cores/@hostContext", "solr");
+ host = cfg.get("solr/cores/@host", null);
- if(shareSchema){
- indexSchemaCache = new ConcurrentHashMap<String ,IndexSchema>();
- }
- adminHandler = cfg.get("solr/cores/@adminHandler", null );
- managementPath = cfg.get("solr/cores/@managementPath", null );
-
- zkClientTimeout = Integer.parseInt(System.getProperty("zkClientTimeout", Integer.toString(zkClientTimeout)));
- initZooKeeper(zkHost, zkClientTimeout);
-
- if (libDir != null) {
- File f = FileUtils.resolvePath(new File(dir), libDir);
- log.info( "loading shared library: "+f.getAbsolutePath() );
- libLoader = SolrResourceLoader.createClassLoader(f, null);
- }
+ if(shareSchema){
+ indexSchemaCache = new ConcurrentHashMap<String ,IndexSchema>();
+ }
+ adminHandler = cfg.get("solr/cores/@adminHandler", null );
+ managementPath = cfg.get("solr/cores/@managementPath", null );
+
+ zkClientTimeout = Integer.parseInt(System.getProperty("zkClientTimeout", Integer.toString(zkClientTimeout)));
+ initZooKeeper(zkHost, zkClientTimeout);
- if (adminPath != null) {
- if (adminHandler == null) {
- coreAdminHandler = new CoreAdminHandler(this);
- } else {
- coreAdminHandler = this.createMultiCoreHandler(adminHandler);
- }
- }
+ if (libDir != null) {
+ File f = FileUtils.resolvePath(new File(dir), libDir);
+ log.info( "loading shared library: "+f.getAbsolutePath() );
+ libLoader = SolrResourceLoader.createClassLoader(f, null);
+ }
- try {
- containerProperties = readProperties(cfg, ((NodeList) cfg.evaluate("solr", XPathConstants.NODESET)).item(0));
- } catch (Throwable e) {
- SolrConfig.severeErrors.add(e);
- SolrException.logOnce(log,null,e);
+ if (adminPath != null) {
+ if (adminHandler == null) {
+ coreAdminHandler = new CoreAdminHandler(this);
+ } else {
+ coreAdminHandler = this.createMultiCoreHandler(adminHandler);
}
+ }
- NodeList nodes = (NodeList)cfg.evaluate("solr/cores/core", XPathConstants.NODESET);
- boolean defaultCoreFound = false;
- for (int i=0; i<nodes.getLength(); i++) {
- Node node = nodes.item(i);
- try {
- String name = DOMUtil.getAttr(node, "name", null);
- if (null == name) {
- throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
- "Each core in solr.xml must have a 'name'");
- }
- if (name.equals(defaultCoreName)){
- // for the default core we use a blank name,
- // later on attempts to access it by it's full name will
- // be mapped to this.
- name="";
- }
- CoreDescriptor p = new CoreDescriptor(this, name, DOMUtil.getAttr(node, "instanceDir", null));
-
- // deal with optional settings
- String opt = DOMUtil.getAttr(node, "config", null);
+ try {
+ containerProperties = readProperties(cfg, ((NodeList) cfg.evaluate("solr", XPathConstants.NODESET)).item(0));
+ } catch (Throwable e) {
+ SolrConfig.severeErrors.add(e);
+ SolrException.logOnce(log,null,e);
+ }
- if (opt != null) {
- p.setConfigName(opt);
- }
- opt = DOMUtil.getAttr(node, "schema", null);
- if (opt != null) {
- p.setSchemaName(opt);
- }
- if (zkController != null) {
- opt = DOMUtil.getAttr(node, "shard", null);
- if (opt != null && opt.length() > 0) {
- p.getCloudDescriptor().setShardId(opt);
- }
- opt = DOMUtil.getAttr(node, "collection", null);
- if (opt != null) {
- p.getCloudDescriptor().setCollectionName(opt);
- }
- }
- opt = DOMUtil.getAttr(node, "properties", null);
- if (opt != null) {
- p.setPropertiesName(opt);
+ NodeList nodes = (NodeList)cfg.evaluate("solr/cores/core", XPathConstants.NODESET);
+ boolean defaultCoreFound = false;
+ for (int i=0; i<nodes.getLength(); i++) {
+ Node node = nodes.item(i);
+ try {
+ String name = DOMUtil.getAttr(node, "name", null);
+ if (null == name) {
+ throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
+ "Each core in solr.xml must have a 'name'");
+ }
+ if (name.equals(defaultCoreName)){
+ // for the default core we use a blank name,
+ // later on attempts to access it by it's full name will
+ // be mapped to this.
+ name="";
+ }
+ CoreDescriptor p = new CoreDescriptor(this, name, DOMUtil.getAttr(node, "instanceDir", null));
+
+ // deal with optional settings
+ String opt = DOMUtil.getAttr(node, "config", null);
+
+ if (opt != null) {
+ p.setConfigName(opt);
+ }
+ opt = DOMUtil.getAttr(node, "schema", null);
+ if (opt != null) {
+ p.setSchemaName(opt);
+ }
+ if (zkController != null) {
+ opt = DOMUtil.getAttr(node, "shard", null);
+ if (opt != null && opt.length() > 0) {
+ p.getCloudDescriptor().setShardId(opt);
}
- opt = DOMUtil.getAttr(node, CoreAdminParams.DATA_DIR, null);
+ opt = DOMUtil.getAttr(node, "collection", null);
if (opt != null) {
- p.setDataDir(opt);
+ p.getCloudDescriptor().setCollectionName(opt);
}
-
- p.setCoreProperties(readProperties(cfg, node));
-
- SolrCore core = create(p);
- register(name, core, false);
}
- catch (Throwable ex) {
- SolrConfig.severeErrors.add( ex );
- SolrException.logOnce(log,null,ex);
+ opt = DOMUtil.getAttr(node, "properties", null);
+ if (opt != null) {
+ p.setPropertiesName(opt);
+ }
+ opt = DOMUtil.getAttr(node, CoreAdminParams.DATA_DIR, null);
+ if (opt != null) {
+ p.setDataDir(opt);
}
+
+ p.setCoreProperties(readProperties(cfg, node));
+
+ SolrCore core = create(p);
+ register(name, core, false);
}
- } finally {
- if (cfgis != null) {
- try { cfgis.close(); } catch (Exception xany) {}
+ catch (Throwable ex) {
+ SolrConfig.severeErrors.add( ex );
+ SolrException.logOnce(log,null,ex);
}
}
-
if(zkController != null) {
try {
synchronized (zkController.getZkStateReader().getUpdateLock()) {
@@ -1025,7 +1020,8 @@ public class CoreContainer
ParserConfigurationException, SAXException, KeeperException,
InterruptedException {
byte[] config = zkController.getConfigFileData(zkConfigName, solrConfigFileName);
- InputStream is = new ByteArrayInputStream(config);
+ InputSource is = new InputSource(new ByteArrayInputStream(config));
+ is.setSystemId(SystemIdResolver.createSystemIdFromResourceName(solrConfigFileName));
SolrConfig cfg = solrConfigFileName == null ? new SolrConfig(
resourceLoader, SolrConfig.DEFAULT_CONF_FILE, is) : new SolrConfig(
resourceLoader, solrConfigFileName, is);
@@ -1037,7 +1033,8 @@ public class CoreContainer
SolrConfig config, SolrResourceLoader resourceLoader)
throws KeeperException, InterruptedException {
byte[] configBytes = zkController.getConfigFileData(zkConfigName, schemaName);
- InputStream is = new ByteArrayInputStream(configBytes);
+ InputSource is = new InputSource(new ByteArrayInputStream(configBytes));
+ is.setSystemId(SystemIdResolver.createSystemIdFromResourceName(schemaName));
IndexSchema schema = new IndexSchema(config, schemaName, is);
return schema;
}
Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/core/RequestHandlers.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/core/RequestHandlers.java?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/core/RequestHandlers.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/core/RequestHandlers.java Wed Mar 30 09:17:25 2011
@@ -17,25 +17,28 @@
package org.apache.solr.core;
+import java.net.URL;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
+import org.apache.solr.common.params.CommonParams;
+import org.apache.solr.common.params.CommonParams.EchoParamStyle;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
+import org.apache.solr.handler.component.SearchHandler;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrRequestHandler;
import org.apache.solr.response.SolrQueryResponse;
-import org.apache.solr.util.plugin.SolrCoreAware;
import org.apache.solr.util.plugin.PluginInfoInitialized;
+import org.apache.solr.util.plugin.SolrCoreAware;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.net.URL;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
/**
*/
final class RequestHandlers {
@@ -68,6 +71,18 @@ final class RequestHandlers {
public RequestHandlers(SolrCore core) {
this.core = core;
+ register(DEFAULT_HANDLER_NAME, getStandardHandler());
+ }
+
+ private SolrRequestHandler getStandardHandler(){
+ SolrRequestHandler standard = core.createRequestHandler(SearchHandler.class.getName());
+ NamedList defParams = new NamedList();
+ defParams.add(CommonParams.HEADER_ECHO_PARAMS, EchoParamStyle.EXPLICIT.toString());
+ defParams.add(CommonParams.ROWS, 10);
+ NamedList nl = new NamedList();
+ nl.add("defaults", defParams);
+ standard.init(nl);
+ return standard;
}
/**
Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/core/SolrConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/core/SolrConfig.java?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/core/SolrConfig.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/core/SolrConfig.java Wed Mar 30 09:17:25 2011
@@ -27,6 +27,7 @@ import org.apache.solr.request.LocalSolr
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrRequestHandler;
import org.apache.solr.response.QueryResponseWriter;
+import org.apache.solr.response.transform.TransformerFactory;
import org.apache.solr.search.CacheConfig;
import org.apache.solr.search.FastLRUCache;
@@ -45,6 +46,7 @@ import org.slf4j.LoggerFactory;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import javax.xml.parsers.ParserConfigurationException;
@@ -102,7 +104,7 @@ public class SolrConfig extends Config {
*@param name the configuration name
*@param is the configuration stream
*/
- public SolrConfig(String name, InputStream is)
+ public SolrConfig(String name, InputSource is)
throws ParserConfigurationException, IOException, SAXException {
this( (SolrResourceLoader) null, name, is );
}
@@ -112,7 +114,7 @@ public class SolrConfig extends Config {
*@param name the configuration name used by the loader if the stream is null
*@param is the configuration stream
*/
- public SolrConfig(String instanceDir, String name, InputStream is)
+ public SolrConfig(String instanceDir, String name, InputSource is)
throws ParserConfigurationException, IOException, SAXException {
this(new SolrResourceLoader(instanceDir), name, is);
}
@@ -124,7 +126,7 @@ public class SolrConfig extends Config {
*@param name the configuration name
*@param is the configuration stream
*/
- SolrConfig(SolrResourceLoader loader, String name, InputStream is)
+ SolrConfig(SolrResourceLoader loader, String name, InputSource is)
throws ParserConfigurationException, IOException, SAXException {
super(loader, name, is, "/config/");
initLibs();
@@ -189,6 +191,7 @@ public class SolrConfig extends Config {
loadPluginInfo(QParserPlugin.class,"queryParser",true, true);
loadPluginInfo(QueryResponseWriter.class,"queryResponseWriter",true, true);
loadPluginInfo(ValueSourceParser.class,"valueSourceParser",true, true);
+ loadPluginInfo(TransformerFactory.class,"transformer",true, true);
loadPluginInfo(SearchComponent.class,"searchComponent",true, true);
loadPluginInfo(QueryConverter.class,"queryConverter",true, true);
@@ -395,7 +398,7 @@ public class SolrConfig extends Config {
* @param type The key is FQN of the plugin class there are a few known types : SolrFormatter, SolrFragmenter
* SolrRequestHandler,QParserPlugin, QueryResponseWriter,ValueSourceParser,
* SearchComponent, QueryConverter, SolrEventListener, DirectoryFactory,
- * IndexDeletionPolicy, IndexReaderFactory
+ * IndexDeletionPolicy, IndexReaderFactory, {@link TransformerFactory}
*/
public List<PluginInfo> getPluginInfos(String type){
List<PluginInfo> result = pluginStore.get(type);
Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/core/SolrCore.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/core/SolrCore.java?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/core/SolrCore.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/core/SolrCore.java Wed Mar 30 09:17:25 2011
@@ -33,16 +33,7 @@ import org.apache.solr.handler.component
import org.apache.solr.highlight.SolrHighlighter;
import org.apache.solr.request.*;
import org.apache.solr.response.*;
-import org.apache.solr.response.BinaryResponseWriter;
-import org.apache.solr.response.JSONResponseWriter;
-import org.apache.solr.response.PHPResponseWriter;
-import org.apache.solr.response.PHPSerializedResponseWriter;
-import org.apache.solr.response.PythonResponseWriter;
-import org.apache.solr.response.QueryResponseWriter;
-import org.apache.solr.response.RawResponseWriter;
-import org.apache.solr.response.RubyResponseWriter;
-import org.apache.solr.response.SolrQueryResponse;
-import org.apache.solr.response.XMLResponseWriter;
+import org.apache.solr.response.transform.TransformerFactory;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.search.QParserPlugin;
import org.apache.solr.search.SolrFieldCacheMBean;
@@ -507,6 +498,7 @@ public final class SolrCore implements S
initWriters();
initQParsers();
initValueSourceParsers();
+ initTransformerFactories();
this.searchComponents = Collections.unmodifiableMap(loadSearchComponents());
@@ -1455,6 +1447,34 @@ public final class SolrCore implements S
}
}
}
+
+
+ private final HashMap<String, TransformerFactory> transformerFactories = new HashMap<String, TransformerFactory>();
+
+ /** Configure the TransformerFactory plugins */
+ private void initTransformerFactories() {
+ // Load any transformer factories
+ initPlugins(transformerFactories,TransformerFactory.class);
+
+ // Tell each transformer what its name is
+ for( Map.Entry<String, TransformerFactory> entry : TransformerFactory.defaultFactories.entrySet() ) {
+ try {
+ String name = entry.getKey();
+ if (null == valueSourceParsers.get(name)) {
+ TransformerFactory f = entry.getValue();
+ transformerFactories.put(name, f);
+ // f.init(null); default ones don't need init
+ }
+ } catch (Exception e) {
+ throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
+ }
+ }
+ }
+
+ public TransformerFactory getTransformerFactory(String name) {
+ return transformerFactories.get(name);
+ }
+
/**
* @param registry The map to which the instance should be added to. The key is the name attribute
Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/AnalysisRequestHandlerBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/AnalysisRequestHandlerBase.java?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/AnalysisRequestHandlerBase.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/AnalysisRequestHandlerBase.java Wed Mar 30 09:17:25 2011
@@ -38,7 +38,6 @@ import org.apache.solr.common.SolrExcept
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.schema.FieldType;
-import org.apache.solr.util.ByteUtils;
import org.apache.noggit.CharArr;
@@ -141,12 +140,12 @@ public abstract class AnalysisRequestHan
final Set<BytesRef> tokens = new HashSet<BytesRef>();
final TokenStream tokenStream = analyzer.tokenStream("", new StringReader(query));
final TermToBytesRefAttribute bytesAtt = tokenStream.getAttribute(TermToBytesRefAttribute.class);
+ final BytesRef bytes = bytesAtt.getBytesRef();
try {
tokenStream.reset();
while (tokenStream.incrementToken()) {
- final BytesRef bytes = new BytesRef();
- bytesAtt.toBytesRef(bytes);
- tokens.add(bytes);
+ bytesAtt.fillBytesRef();
+ tokens.add(new BytesRef(bytes));
}
} catch (IOException ioe) {
throw new RuntimeException("Error occured while iterating over tokenstream", ioe);
@@ -236,12 +235,13 @@ public abstract class AnalysisRequestHan
FieldType fieldType = context.getFieldType();
- final BytesRef rawBytes = new BytesRef();
final CharArr textBuf = new CharArr();
for (int i = 0, c = tokens.size(); i < c; i++) {
AttributeSource token = tokens.get(i);
final NamedList<Object> tokenNamedList = new SimpleOrderedMap<Object>();
- token.getAttribute(TermToBytesRefAttribute.class).toBytesRef(rawBytes);
+ final TermToBytesRefAttribute termAtt = token.getAttribute(TermToBytesRefAttribute.class);
+ BytesRef rawBytes = termAtt.getBytesRef();
+ termAtt.fillBytesRef();
textBuf.reset();
fieldType.indexedToReadable(rawBytes, textBuf);
Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/DocumentAnalysisRequestHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/DocumentAnalysisRequestHandler.java?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/DocumentAnalysisRequestHandler.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/DocumentAnalysisRequestHandler.java Wed Mar 30 09:17:25 2011
@@ -30,6 +30,7 @@ import org.apache.solr.common.util.Conte
import org.apache.solr.common.util.ContentStreamBase;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
+import org.apache.solr.common.util.XMLErrorLogger;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.schema.FieldType;
import org.apache.solr.schema.IndexSchema;
@@ -78,6 +79,7 @@ import java.util.*;
public class DocumentAnalysisRequestHandler extends AnalysisRequestHandlerBase {
public static final Logger log = LoggerFactory.getLogger(DocumentAnalysisRequestHandler.class);
+ private static final XMLErrorLogger xmllog = new XMLErrorLogger(log);
private static final float DEFAULT_BOOST = 1.0f;
@@ -101,6 +103,7 @@ public class DocumentAnalysisRequestHand
// isimplementation specific.
log.debug("Unable to set the 'reuse-instance' property for the input factory: " + inputFactory);
}
+ inputFactory.setXMLReporter(xmllog);
}
/**
Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/MoreLikeThisHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/MoreLikeThisHandler.java?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/MoreLikeThisHandler.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/MoreLikeThisHandler.java Wed Mar 30 09:17:25 2011
@@ -77,10 +77,11 @@ public class MoreLikeThisHandler extends
SolrParams params = req.getParams();
// Set field flags
- String fl = params.get(CommonParams.FL);
+ ReturnFields returnFields = new ReturnFields( req );
+ rsp.setReturnFields( returnFields );
int flags = 0;
- if (fl != null) {
- flags |= SolrPluginUtils.setReturnFields(fl, rsp);
+ if (returnFields.wantsScore()) {
+ flags |= SolrIndexSearcher.GET_SCORES;
}
String defType = params.get(QueryParsing.DEFTYPE, QParserPlugin.DEFAULT_QTYPE);
Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/XmlUpdateRequestHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/XmlUpdateRequestHandler.java?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/XmlUpdateRequestHandler.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/XmlUpdateRequestHandler.java Wed Mar 30 09:17:25 2011
@@ -20,6 +20,7 @@ package org.apache.solr.handler;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.XML;
+import org.apache.solr.common.util.XMLErrorLogger;
import org.apache.solr.core.SolrCore;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.request.SolrQueryRequest;
@@ -40,6 +41,7 @@ import java.util.HashMap;
*/
public class XmlUpdateRequestHandler extends ContentStreamHandlerBase {
public static Logger log = LoggerFactory.getLogger(XmlUpdateRequestHandler.class);
+ private static final XMLErrorLogger xmllog = new XMLErrorLogger(log);
public static final String UPDATE_PROCESSOR = "update.processor";
@@ -78,6 +80,7 @@ public class XmlUpdateRequestHandler ext
// isimplementation specific.
log.debug("Unable to set the 'reuse-instance' property for the input chain: " + inputFactory);
}
+ inputFactory.setXMLReporter(xmllog);
}
@Override
Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java Wed Mar 30 09:17:25 2011
@@ -586,7 +586,7 @@ public class LukeRequestHandler extends
public TermHistogram histogram;
TopTermQueue(int size) {
- initialize(size);
+ super(size);
histogram = new TermHistogram();
}
Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/component/QueryComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/component/QueryComponent.java?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/component/QueryComponent.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/component/QueryComponent.java Wed Mar 30 09:17:25 2011
@@ -39,6 +39,7 @@ import org.apache.solr.common.util.Named
import org.apache.solr.common.util.StrUtils;
import org.apache.solr.core.CoreDescriptor;
import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.ResultContext;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.schema.FieldType;
import org.apache.solr.schema.SchemaField;
@@ -72,13 +73,14 @@ public class QueryComponent extends Sear
}
SolrQueryResponse rsp = rb.rsp;
- // Set field flags
- String fl = params.get(CommonParams.FL);
- int fieldFlags = 0;
- if (fl != null) {
- fieldFlags |= SolrPluginUtils.setReturnFields(fl, rsp);
+ // Set field flags
+ ReturnFields returnFields = new ReturnFields( req );
+ rsp.setReturnFields( returnFields );
+ int flags = 0;
+ if (returnFields.wantsScore()) {
+ flags |= SolrIndexSearcher.GET_SCORES;
}
- rb.setFieldFlags( fieldFlags );
+ rb.setFieldFlags( flags );
String defType = params.get(QueryParsing.DEFTYPE,QParserPlugin.DEFAULT_QTYPE);
@@ -294,7 +296,11 @@ public class QueryComponent extends Sear
res.docSet = searcher.getDocSet(queries);
}
rb.setResults(res);
- rsp.add("response",rb.getResults().docList);
+
+ ResultContext ctx = new ResultContext();
+ ctx.docs = rb.getResults().docList;
+ ctx.query = null; // anything?
+ rsp.add("response", ctx);
return;
}
@@ -416,7 +422,10 @@ public class QueryComponent extends Sear
// TODO: get "hits" a different way to log
if (grouping.mainResult != null) {
- rsp.add("response",grouping.mainResult);
+ ResultContext ctx = new ResultContext();
+ ctx.docs = grouping.mainResult;
+ ctx.query = null; // TODO? add the query?
+ rsp.add("response", ctx);
rsp.getToLog().add("hits", grouping.mainResult.matches());
}
@@ -431,7 +440,11 @@ public class QueryComponent extends Sear
searcher.search(result,cmd);
rb.setResult( result );
- rsp.add("response",rb.getResults().docList);
+
+ ResultContext ctx = new ResultContext();
+ ctx.docs = rb.getResults().docList;
+ ctx.query = rb.getQuery();
+ rsp.add("response", ctx);
rsp.getToLog().add("hits", rb.getResults().docList.matches());
doFieldSortValues(rb, searcher);
Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/component/QueryElevationComponent.java?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/component/QueryElevationComponent.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/component/QueryElevationComponent.java Wed Mar 30 09:17:25 2011
@@ -67,6 +67,7 @@ import org.apache.solr.util.plugin.SolrC
import org.apache.solr.request.SolrQueryRequest;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
/**
* A component to elevate some documents to the top of the result set.
@@ -230,7 +231,7 @@ public class QueryElevationComponent ext
log.info( "Loading QueryElevation from data dir: "+f );
InputStream is = VersionedFile.getLatestFile( core.getDataDir(), f );
- Config cfg = new Config( core.getResourceLoader(), f, is, null );
+ Config cfg = new Config( core.getResourceLoader(), f, new InputSource(is), null );
map = loadElevationMap( cfg );
elevationCache.put( reader, map );
}
Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/component/ShardDoc.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/component/ShardDoc.java?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/component/ShardDoc.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/component/ShardDoc.java Wed Mar 30 09:17:25 2011
@@ -82,6 +82,7 @@ class ShardFieldSortedHitQueue extends P
protected List<String> fieldNames = new ArrayList<String>();
public ShardFieldSortedHitQueue(SortField[] fields, int size) {
+ super(size);
final int n = fields.length;
comparators = new Comparator[n];
this.fields = new SortField[n];
@@ -95,10 +96,10 @@ class ShardFieldSortedHitQueue extends P
String fieldname = fields[i].getField();
comparators[i] = getCachedComparator(fieldname, fields[i]
- .getType(), fields[i].getLocale(), fields[i].getComparatorSource());
+ .getType(), fields[i].getComparatorSource());
if (fields[i].getType() == SortField.STRING) {
- this.fields[i] = new SortField(fieldname, fields[i].getLocale(),
+ this.fields[i] = new SortField(fieldname, SortField.STRING,
fields[i].getReverse());
} else {
this.fields[i] = new SortField(fieldname, fields[i].getType(),
@@ -107,8 +108,6 @@ class ShardFieldSortedHitQueue extends P
//System.out.println("%%%%%%%%%%%%%%%%%% got "+fields[i].getType() +" for "+ fieldname +" fields[i].getReverse(): "+fields[i].getReverse());
}
-
- initialize(size);
}
@Override
@@ -145,17 +144,14 @@ class ShardFieldSortedHitQueue extends P
return c < 0;
}
- Comparator getCachedComparator(String fieldname, int type, Locale locale, FieldComparatorSource factory) {
+ Comparator getCachedComparator(String fieldname, int type, FieldComparatorSource factory) {
Comparator comparator = null;
switch (type) {
case SortField.SCORE:
comparator = comparatorScore(fieldname);
break;
case SortField.STRING:
- if (locale != null)
- comparator = comparatorStringLocale(fieldname, locale);
- else
- comparator = comparatorNatural(fieldname);
+ comparator = comparatorNatural(fieldname);
break;
case SortField.CUSTOM:
if (factory instanceof MissingStringLastComparatorSource){
Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/component/SpellCheckComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/component/SpellCheckComponent.java?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/component/SpellCheckComponent.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/handler/component/SpellCheckComponent.java Wed Mar 30 09:17:25 2011
@@ -47,7 +47,8 @@ import org.apache.solr.common.params.Com
import org.apache.solr.common.params.ShardParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.params.SpellingParams;
-import org.apache.solr.common.util.NamedList;import org.apache.solr.common.util.SimpleOrderedMap;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.core.SolrCore;
import org.apache.solr.core.SolrEventListener;
import org.apache.solr.core.SolrResourceLoader;
Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/request/PerSegmentSingleValuedFaceting.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/request/PerSegmentSingleValuedFaceting.java?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/request/PerSegmentSingleValuedFaceting.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/request/PerSegmentSingleValuedFaceting.java Wed Mar 30 09:17:25 2011
@@ -114,10 +114,7 @@ class PerSegmentSingleValuedFaceting {
// now merge the per-segment results
- PriorityQueue<SegFacet> queue = new PriorityQueue<SegFacet>() {
- {
- initialize(leaves.length);
- }
+ PriorityQueue<SegFacet> queue = new PriorityQueue<SegFacet>(leaves.length) {
@Override
protected boolean lessThan(SegFacet a, SegFacet b) {
return a.tempBR.compareTo(b.tempBR) < 0;
Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/request/SimpleFacets.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/request/SimpleFacets.java?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/request/SimpleFacets.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/request/SimpleFacets.java Wed Mar 30 09:17:25 2011
@@ -857,8 +857,16 @@ public class SimpleFacets {
final int minCount = params.getFieldInt(f,FacetParams.FACET_MINCOUNT, 0);
- final EnumSet<FacetRangeInclude> include = FacetRangeInclude.parseParam
- (params.getFieldParams(f,FacetParams.FACET_DATE_INCLUDE));
+ String[] iStrs = params.getFieldParams(f,FacetParams.FACET_DATE_INCLUDE);
+ // Legacy support for default of [lower,upper,edge] for date faceting
+ // this is not handled by FacetRangeInclude.parseParam because
+ // range faceting has differnet defaults
+ final EnumSet<FacetRangeInclude> include =
+ (null == iStrs || 0 == iStrs.length ) ?
+ EnumSet.of(FacetRangeInclude.LOWER,
+ FacetRangeInclude.UPPER,
+ FacetRangeInclude.EDGE)
+ : FacetRangeInclude.parseParam(iStrs);
try {
Date low = start;
Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/response/BaseResponseWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/response/BaseResponseWriter.java?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/response/BaseResponseWriter.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/response/BaseResponseWriter.java Wed Mar 30 09:17:25 2011
@@ -24,6 +24,7 @@ import org.apache.solr.common.SolrInputD
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.search.DocList;
+import org.apache.solr.search.ReturnFields;
import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.search.DocIterator;
import org.apache.solr.schema.FieldType;
@@ -38,10 +39,14 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.List;
-import java.util.Set;
import java.util.ArrayList;
/**
+ * THIS HAS NO TESTS and is not used anywhere.... no idea how or if it should work...
+ *
+ * I think we should drop it - along with {@link GenericBinaryResponseWriter} and {@link GenericBinaryResponseWriter}
+ *
+ * unless I'm missing something (ryan, March 2011)
*
*
* This class serves as a basis from which {@link QueryResponseWriter}s can be
@@ -60,7 +65,6 @@ public abstract class BaseResponseWriter
private static final Logger LOG = LoggerFactory
.getLogger(BaseResponseWriter.class);
- private static final String SCORE_FIELD = "score";
/**
*
@@ -110,9 +114,6 @@ public abstract class BaseResponseWriter
responseWriter.startDocumentList(name,info);
for (int j = 0; j < sz; j++) {
SolrDocument sdoc = getDoc(iterator.nextDoc(), idxInfo);
- if (idxInfo.includeScore && docList.hasScores()) {
- sdoc.addField(SCORE_FIELD, iterator.score());
- }
responseWriter.writeDoc(sdoc);
}
} else {
@@ -120,9 +121,6 @@ public abstract class BaseResponseWriter
.size());
for (int j = 0; j < sz; j++) {
SolrDocument sdoc = getDoc(iterator.nextDoc(), idxInfo);
- if (idxInfo.includeScore && docList.hasScores()) {
- sdoc.addField(SCORE_FIELD, iterator.score());
- }
list.add(sdoc);
}
responseWriter.writeAllDocs(info, list);
@@ -144,22 +142,13 @@ public abstract class BaseResponseWriter
private static class IdxInfo {
IndexSchema schema;
SolrIndexSearcher searcher;
- Set<String> returnFields;
- boolean includeScore;
+ ReturnFields returnFields;
private IdxInfo(IndexSchema schema, SolrIndexSearcher searcher,
- Set<String> returnFields) {
+ ReturnFields returnFields) {
this.schema = schema;
this.searcher = searcher;
- this.includeScore = returnFields != null
- && returnFields.contains(SCORE_FIELD);
- if (returnFields != null) {
- if (returnFields.size() == 0 || (returnFields.size() == 1 && includeScore) || returnFields.contains("*")) {
- returnFields = null; // null means return all stored fields
- }
- }
this.returnFields = returnFields;
-
}
}
@@ -168,7 +157,7 @@ public abstract class BaseResponseWriter
SolrDocument solrDoc = new SolrDocument();
for (Fieldable f : doc.getFields()) {
String fieldName = f.name();
- if (info.returnFields != null && !info.returnFields.contains(fieldName))
+ if (info.returnFields != null && !info.returnFields.wantsField(fieldName))
continue;
SchemaField sf = info.schema.getFieldOrNull(fieldName);
FieldType ft = null;
Modified: lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/response/BinaryResponseWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/response/BinaryResponseWriter.java?rev=1086876&r1=1086875&r2=1086876&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/response/BinaryResponseWriter.java (original)
+++ lucene/dev/branches/realtime_search/solr/src/java/org/apache/solr/response/BinaryResponseWriter.java Wed Mar 30 09:17:25 2011
@@ -19,13 +19,16 @@ package org.apache.solr.response;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Fieldable;
import org.apache.solr.common.SolrDocument;
+import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.JavaBinCodec;
import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.transform.DocTransformer;
+import org.apache.solr.response.transform.TransformContext;
import org.apache.solr.schema.*;
-import org.apache.solr.search.DocIterator;
import org.apache.solr.search.DocList;
+import org.apache.solr.search.ReturnFields;
import org.apache.solr.search.SolrIndexSearcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -62,79 +65,101 @@ public class BinaryResponseWriter implem
protected final SolrQueryRequest solrQueryRequest;
protected IndexSchema schema;
protected SolrIndexSearcher searcher;
- protected final Set<String> returnFields;
- protected final boolean includeScore;
+ protected final ReturnFields returnFields;
// transmit field values using FieldType.toObject()
// rather than the String from FieldType.toExternal()
boolean useFieldObjects = true;
- public Resolver(SolrQueryRequest req, Set<String> returnFields) {
+ public Resolver(SolrQueryRequest req, ReturnFields returnFields) {
solrQueryRequest = req;
- this.includeScore = returnFields != null && returnFields.contains("score");
-
- if (returnFields != null) {
- if (returnFields.size() == 0 || (returnFields.size() == 1 && includeScore) || returnFields.contains("*")) {
- returnFields = null; // null means return all stored fields
- }
- }
this.returnFields = returnFields;
}
public Object resolve(Object o, JavaBinCodec codec) throws IOException {
+ if (o instanceof ResultContext) {
+ writeResults((ResultContext) o, codec);
+ return null; // null means we completely handled it
+ }
if (o instanceof DocList) {
- writeDocList((DocList) o, codec);
+ ResultContext ctx = new ResultContext();
+ ctx.docs = (DocList) o;
+ writeResults(ctx, codec);
return null; // null means we completely handled it
}
+
if (o instanceof SolrDocument) {
- SolrDocument solrDocument = (SolrDocument) o;
- codec.writeSolrDocument(solrDocument, returnFields);
- return null;
- }
- if (o instanceof Document) {
- return getDoc((Document) o);
+ // Remove any fields that were not requested
+ // This typically happens when distributed search adds extra fields to an internal request
+ SolrDocument doc = (SolrDocument)o;
+ for( String fname : doc.getFieldNames() ) {
+ if( !returnFields.wantsField( fname ) ) {
+ doc.removeFields( fname );
+ }
+ }
+ return doc;
}
-
return o;
}
- public void writeDocList(DocList ids, JavaBinCodec codec) throws IOException {
- codec.writeTag(JavaBinCodec.SOLRDOCLST);
- List l = new ArrayList(3);
- l.add((long) ids.matches());
- l.add((long) ids.offset());
- Float maxScore = null;
- if (includeScore && ids.hasScores()) {
- maxScore = ids.maxScore();
- }
- l.add(maxScore);
- codec.writeArray(l);
-
+ protected void writeResultsBody( ResultContext res, JavaBinCodec codec ) throws IOException
+ {
+ DocList ids = res.docs;
+ TransformContext context = new TransformContext();
+ context.query = res.query;
+ context.wantsScores = returnFields.wantsScore() && ids.hasScores();
+
int sz = ids.size();
codec.writeTag(JavaBinCodec.ARR, sz);
if(searcher == null) searcher = solrQueryRequest.getSearcher();
if(schema == null) schema = solrQueryRequest.getSchema();
- DocIterator iterator = ids.iterator();
+
+ context.searcher = searcher;
+ DocTransformer transformer = returnFields.getTransformer();
+ if( transformer != null ) {
+ transformer.setContext( context );
+ }
+
+ Set<String> fnames = returnFields.getLuceneFieldNames();
+ context.iterator = ids.iterator();
for (int i = 0; i < sz; i++) {
- int id = iterator.nextDoc();
- Document doc = searcher.doc(id, returnFields);
-
+ int id = context.iterator.nextDoc();
+ Document doc = searcher.doc(id, fnames);
SolrDocument sdoc = getDoc(doc);
-
- if (includeScore && ids.hasScores()) {
- sdoc.addField("score", iterator.score());
+ if( transformer != null ) {
+ transformer.transform(sdoc, id );
}
-
codec.writeSolrDocument(sdoc);
}
+ if( transformer != null ) {
+ transformer.setContext( null );
+ }
+ }
+
+ public void writeResults(ResultContext ctx, JavaBinCodec codec) throws IOException {
+ codec.writeTag(JavaBinCodec.SOLRDOCLST);
+ boolean wantsScores = returnFields.wantsScore() && ctx.docs.hasScores();
+ List l = new ArrayList(3);
+ l.add((long) ctx.docs.matches());
+ l.add((long) ctx.docs.offset());
+
+ Float maxScore = null;
+ if (wantsScores) {
+ maxScore = ctx.docs.maxScore();
+ }
+ l.add(maxScore);
+ codec.writeArray(l);
+
+ // this is a seprate function so that streaming responses can use just that part
+ writeResultsBody( ctx, codec );
}
-
public SolrDocument getDoc(Document doc) {
SolrDocument solrDoc = new SolrDocument();
for (Fieldable f : doc.getFields()) {
String fieldName = f.name();
- if (returnFields != null && !returnFields.contains(fieldName)) continue;
+ if( !returnFields.wantsField(fieldName) )
+ continue;
SchemaField sf = schema.getFieldOrNull(fieldName);
FieldType ft = null;
if(sf != null) ft =sf.getType();