mirror of https://github.com/apache/lucene.git
make json response writers available by default
git-svn-id: https://svn.apache.org/repos/asf/incubator/solr/trunk@423629 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e6f9c04807
commit
e24147b019
|
@ -223,15 +223,17 @@
|
||||||
writer.
|
writer.
|
||||||
The "standard" writer is the default and will be used if 'wt' is not specified
|
The "standard" writer is the default and will be used if 'wt' is not specified
|
||||||
in the request. XMLResponseWriter will be used if nothing specified here.
|
in the request. XMLResponseWriter will be used if nothing specified here.
|
||||||
|
The json, python, and ruby writers are also available by default.
|
||||||
<queryResponseWriter name="standard" class="org.apache.solr.request.XMLResponseWriter"/>
|
|
||||||
<queryResponseWriter name="custom" class="com.example.MyResponseWriter"/>
|
|
||||||
-->
|
|
||||||
|
|
||||||
|
<queryResponseWriter name="standard" class="org.apache.solr.request.XMLResponseWriter"/>
|
||||||
<queryResponseWriter name="json" class="org.apache.solr.request.JSONResponseWriter"/>
|
<queryResponseWriter name="json" class="org.apache.solr.request.JSONResponseWriter"/>
|
||||||
<queryResponseWriter name="python" class="org.apache.solr.request.PythonResponseWriter"/>
|
<queryResponseWriter name="python" class="org.apache.solr.request.PythonResponseWriter"/>
|
||||||
<queryResponseWriter name="ruby" class="org.apache.solr.request.RubyResponseWriter"/>
|
<queryResponseWriter name="ruby" class="org.apache.solr.request.RubyResponseWriter"/>
|
||||||
|
|
||||||
|
<queryResponseWriter name="custom" class="com.example.MyResponseWriter"/>
|
||||||
|
-->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- config for the admin interface -->
|
<!-- config for the admin interface -->
|
||||||
<admin>
|
<admin>
|
||||||
|
|
|
@ -16,17 +16,11 @@
|
||||||
|
|
||||||
package org.apache.solr.core;
|
package org.apache.solr.core;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.TreeMap;
|
|
||||||
import org.apache.lucene.index.IndexReader;
|
import org.apache.lucene.index.IndexReader;
|
||||||
import org.apache.lucene.search.BooleanQuery;
|
import org.apache.lucene.search.BooleanQuery;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
import org.apache.lucene.store.FSDirectory;
|
import org.apache.lucene.store.FSDirectory;
|
||||||
import org.apache.solr.request.QueryResponseWriter;
|
import org.apache.solr.request.*;
|
||||||
import org.apache.solr.request.SolrRequestHandler;
|
|
||||||
import org.apache.solr.request.SolrQueryRequest;
|
|
||||||
import org.apache.solr.request.SolrQueryResponse;
|
|
||||||
import org.apache.solr.request.XMLResponseWriter;
|
|
||||||
import org.apache.solr.schema.IndexSchema;
|
import org.apache.solr.schema.IndexSchema;
|
||||||
import org.apache.solr.schema.SchemaField;
|
import org.apache.solr.schema.SchemaField;
|
||||||
import org.apache.solr.search.SolrIndexSearcher;
|
import org.apache.solr.search.SolrIndexSearcher;
|
||||||
|
@ -47,8 +41,7 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
@ -956,8 +949,7 @@ public final class SolrCore {
|
||||||
|
|
||||||
|
|
||||||
private QueryResponseWriter defaultResponseWriter;
|
private QueryResponseWriter defaultResponseWriter;
|
||||||
private Map<String, QueryResponseWriter> responseWriters
|
private final Map<String, QueryResponseWriter> responseWriters = new HashMap<String, QueryResponseWriter>();
|
||||||
= new TreeMap<String, QueryResponseWriter>();
|
|
||||||
|
|
||||||
/** Configure the query response writers. There will always be a default writer; additional
|
/** Configure the query response writers. There will always be a default writer; additional
|
||||||
* writers may also be configured. */
|
* writers may also be configured. */
|
||||||
|
@ -988,6 +980,18 @@ public final class SolrCore {
|
||||||
if (defaultResponseWriter == null) {
|
if (defaultResponseWriter == null) {
|
||||||
defaultResponseWriter = new XMLResponseWriter();
|
defaultResponseWriter = new XMLResponseWriter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make JSON response writers available by default
|
||||||
|
if (responseWriters.get("json")==null) {
|
||||||
|
responseWriters.put("json", new JSONResponseWriter());
|
||||||
|
}
|
||||||
|
if (responseWriters.get("python")==null) {
|
||||||
|
responseWriters.put("python", new PythonResponseWriter());
|
||||||
|
}
|
||||||
|
if (responseWriters.get("ruby")==null) {
|
||||||
|
responseWriters.put("ruby", new RubyResponseWriter());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Finds a writer by name, or returns the default writer if not found. */
|
/** Finds a writer by name, or returns the default writer if not found. */
|
||||||
|
|
Loading…
Reference in New Issue