mirror of https://github.com/apache/lucene.git
SOLR-1367: Reverted, but kept the simple docList test, with modifications
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@805866 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1b289c4f35
commit
a86d0c24c3
|
@ -267,11 +267,9 @@ New Features
|
||||||
HTMLStripStandardTokenizerFactory deprecated. To strip HTML tags, HTMLStripCharFilter can be used
|
HTMLStripStandardTokenizerFactory deprecated. To strip HTML tags, HTMLStripCharFilter can be used
|
||||||
with an arbitrary Tokenizer. (koji)
|
with an arbitrary Tokenizer. (koji)
|
||||||
|
|
||||||
68. SOLR-1367: Added callback mechanism for converting DocList to SolrDocumentList in SolrPluginUtils (gsingers)
|
68. SOLR-1275: Add expungeDeletes to DirectUpdateHandler2 (noble)
|
||||||
|
|
||||||
69. SOLR-1275: Add expungeDeletes to DirectUpdateHandler2 (noble)
|
69. SOLR-1372: Enhance FieldAnalysisRequestHandler to accept field value from content stream (ehatcher)
|
||||||
|
|
||||||
70. SOLR-1372: Enhance FieldAnalysisRequestHandler to accept field value from content stream (ehatcher)
|
|
||||||
|
|
||||||
|
|
||||||
Optimizations
|
Optimizations
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
package org.apache.solr.util;
|
|
||||||
/**
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import org.apache.solr.common.SolrDocument;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback capability for modifying a SolrDocument in the {@link SolrPluginUtils#docListToSolrDocumentList(org.apache.solr.search.DocList, org.apache.solr.search.SolrIndexSearcher, java.util.Set, java.util.Map)}
|
|
||||||
*
|
|
||||||
* <p/>
|
|
||||||
* NOTE: This API is subject to change.
|
|
||||||
* Due to https://issues.apache.org/jira/browse/SOLR-1298 and https://issues.apache.org/jira/browse/SOLR-705, this interface may change in the future.
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
public interface SolrDocumentModifier {
|
|
||||||
/**
|
|
||||||
* Implement this method to allow for changes to be made to the {@link org.apache.solr.common.SolrDocument} in the {@link SolrPluginUtils#docListToSolrDocumentList(org.apache.solr.search.DocList, org.apache.solr.search.SolrIndexSearcher, java.util.Set, SolrDocumentModifier, java.util.Map)}
|
|
||||||
* call.
|
|
||||||
* @param doc The {@link org.apache.solr.common.SolrDocument} that can be modified.
|
|
||||||
*/
|
|
||||||
void process(SolrDocument doc);
|
|
||||||
}
|
|
|
@ -887,16 +887,6 @@ public class SolrPluginUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static SolrDocumentList docListToSolrDocumentList(
|
|
||||||
DocList docs,
|
|
||||||
SolrIndexSearcher searcher,
|
|
||||||
Set<String> fields,
|
|
||||||
Map<SolrDocument, Integer> ids ) throws IOException
|
|
||||||
{
|
|
||||||
return docListToSolrDocumentList(docs, searcher, fields, null, ids);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a DocList to a SolrDocumentList
|
* Convert a DocList to a SolrDocumentList
|
||||||
*
|
*
|
||||||
|
@ -906,17 +896,17 @@ public class SolrPluginUtils {
|
||||||
* @param docs The {@link org.apache.solr.search.DocList} to convert
|
* @param docs The {@link org.apache.solr.search.DocList} to convert
|
||||||
* @param searcher The {@link org.apache.solr.search.SolrIndexSearcher} to use to load the docs from the Lucene index
|
* @param searcher The {@link org.apache.solr.search.SolrIndexSearcher} to use to load the docs from the Lucene index
|
||||||
* @param fields The names of the Fields to load
|
* @param fields The names of the Fields to load
|
||||||
* @param docModifier The {@link SolrDocumentModifier}
|
|
||||||
* @param ids A map to store the ids of the docs
|
* @param ids A map to store the ids of the docs
|
||||||
* @return The new {@link org.apache.solr.common.SolrDocumentList} containing all the loaded docs
|
* @return The new {@link org.apache.solr.common.SolrDocumentList} containing all the loaded docs
|
||||||
* @throws java.io.IOException if there was a problem loading the docs
|
* @throws java.io.IOException if there was a problem loading the docs
|
||||||
* @since solr 1.4
|
* @since solr 1.4
|
||||||
*/
|
*/
|
||||||
public static SolrDocumentList docListToSolrDocumentList(
|
public static SolrDocumentList docListToSolrDocumentList(
|
||||||
DocList docs,
|
DocList docs,
|
||||||
SolrIndexSearcher searcher,
|
SolrIndexSearcher searcher,
|
||||||
Set<String> fields, SolrDocumentModifier docModifier,
|
Set<String> fields,
|
||||||
Map<SolrDocument, Integer> ids ) throws IOException{
|
Map<SolrDocument, Integer> ids ) throws IOException
|
||||||
|
{
|
||||||
DocumentBuilder db = new DocumentBuilder(searcher.getSchema());
|
DocumentBuilder db = new DocumentBuilder(searcher.getSchema());
|
||||||
SolrDocumentList list = new SolrDocumentList();
|
SolrDocumentList list = new SolrDocumentList();
|
||||||
list.setNumFound(docs.matches());
|
list.setNumFound(docs.matches());
|
||||||
|
@ -940,9 +930,6 @@ public class SolrPluginUtils {
|
||||||
doc.addField("score", 0.0f);
|
doc.addField("score", 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (docModifier != null) {
|
|
||||||
docModifier.process(doc);
|
|
||||||
}
|
|
||||||
list.add( doc );
|
list.add( doc );
|
||||||
|
|
||||||
if( ids != null ) {
|
if( ids != null ) {
|
||||||
|
@ -953,6 +940,7 @@ public class SolrPluginUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a SolrQueryResponse replace the DocList if it is in the result.
|
* Given a SolrQueryResponse replace the DocList if it is in the result.
|
||||||
* Otherwise add it to the response
|
* Otherwise add it to the response
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class SolrPluginUtilsTest extends AbstractSolrTestCase {
|
||||||
public String getSolrConfigFile() { return "solrconfig.xml"; }
|
public String getSolrConfigFile() { return "solrconfig.xml"; }
|
||||||
|
|
||||||
|
|
||||||
public void testDocModifier() throws Exception {
|
public void testDocListConversion() throws Exception {
|
||||||
assertU("", adoc("id", "3234", "val_t", "quick red fox"));
|
assertU("", adoc("id", "3234", "val_t", "quick red fox"));
|
||||||
assertU("", adoc("id", "3235", "val_t", "quick green fox"));
|
assertU("", adoc("id", "3235", "val_t", "quick green fox"));
|
||||||
assertU("", adoc("id", "3236", "val_t", "quick brown fox"));
|
assertU("", adoc("id", "3236", "val_t", "quick brown fox"));
|
||||||
|
@ -69,16 +69,11 @@ public class SolrPluginUtilsTest extends AbstractSolrTestCase {
|
||||||
Set<String> fields = new HashSet<String>();
|
Set<String> fields = new HashSet<String>();
|
||||||
fields.add("val_t");
|
fields.add("val_t");
|
||||||
|
|
||||||
SolrDocumentModifier docMod = new SolrDocumentModifier() {
|
|
||||||
public void process(SolrDocument doc) {
|
|
||||||
doc.addField("junk", "foo");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
SolrDocumentList list = SolrPluginUtils.docListToSolrDocumentList(docs, srchr, fields, docMod, null);
|
SolrDocumentList list = SolrPluginUtils.docListToSolrDocumentList(docs, srchr, fields, null);
|
||||||
assertTrue("list Size: " + list.size() + " is not: " + docs.size(), list.size() == docs.size());
|
assertTrue("list Size: " + list.size() + " is not: " + docs.size(), list.size() == docs.size());
|
||||||
for (SolrDocument document : list) {
|
for (SolrDocument document : list) {
|
||||||
assertNotNull(document.get("junk"));
|
assertNotNull(document.get("val_t"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue