You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ab...@apache.org on 2017/03/03 21:37:11 UTC
[10/19] lucene-solr:jira/solr-9858: LUCENE-6819: Remove index-time
boosts.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8ed2b764/solr/core/src/test/org/apache/solr/schema/TestSchemalessBufferedUpdates.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/schema/TestSchemalessBufferedUpdates.java b/solr/core/src/test/org/apache/solr/schema/TestSchemalessBufferedUpdates.java
index c2e8b2e..ca48f78 100644
--- a/solr/core/src/test/org/apache/solr/schema/TestSchemalessBufferedUpdates.java
+++ b/solr/core/src/test/org/apache/solr/schema/TestSchemalessBufferedUpdates.java
@@ -149,7 +149,7 @@ public class TestSchemalessBufferedUpdates extends SolrTestCaseJ4 {
// Non-JSON types (Date in this case) aren't handled properly in noggit-0.6. Although this is fixed in
// https://github.com/yonik/noggit/commit/ec3e732af7c9425e8f40297463cbe294154682b1 to call obj.toString(),
// Date::toString produces a Date representation that Solr doesn't like, so we convert using Instant::toString
- cmd.solrDoc.get("f_dt").setValue(((Date) cmd.solrDoc.get("f_dt").getValue()).toInstant().toString(), 1.0f);
+ cmd.solrDoc.get("f_dt").setValue(((Date) cmd.solrDoc.get("f_dt").getValue()).toInstant().toString());
}
return cmd.solrDoc;
} finally {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8ed2b764/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java b/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java
index 8c65b58..92f2863 100644
--- a/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java
+++ b/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java
@@ -432,7 +432,6 @@ public class TestFunctionQuery extends SolrTestCaseJ4 {
"//float[@name='score']='" + similarity.tf(5) + "'");
FieldInvertState state = new FieldInvertState("a_tfidf");
- state.setBoost(1.0f);
state.setLength(4);
long norm = similarity.computeNorm(state);
float nrm = similarity.decodeNormValue((byte) norm);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8ed2b764/solr/core/src/test/org/apache/solr/update/DocumentBuilderTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/update/DocumentBuilderTest.java b/solr/core/src/test/org/apache/solr/update/DocumentBuilderTest.java
index 2c0b634..2a78d6b 100644
--- a/solr/core/src/test/org/apache/solr/update/DocumentBuilderTest.java
+++ b/solr/core/src/test/org/apache/solr/update/DocumentBuilderTest.java
@@ -16,30 +16,15 @@
*/
package org.apache.solr.update;
-import java.util.List;
-
import org.apache.lucene.document.Document;
-import org.apache.lucene.index.IndexableField;
-import org.apache.lucene.index.LeafReader;
-import org.apache.lucene.index.NumericDocValues;
-import org.apache.lucene.search.similarities.ClassicSimilarity;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.SolrInputField;
-import org.apache.solr.common.params.CommonParams;
import org.apache.solr.core.SolrCore;
-import org.apache.solr.index.SlowCompositeReaderWrapper;
-import org.apache.solr.request.SolrQueryRequest;
-import org.apache.solr.response.ResultContext;
-import org.apache.solr.response.SolrQueryResponse;
-import org.apache.solr.schema.CopyField;
import org.apache.solr.schema.FieldType;
-import org.apache.solr.schema.IndexSchema;
-import org.apache.solr.search.DocList;
-import org.apache.solr.search.SolrIndexSearcher;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -62,7 +47,7 @@ public class DocumentBuilderTest extends SolrTestCaseJ4 {
// undefined field
try {
SolrInputDocument doc = new SolrInputDocument();
- doc.setField( "unknown field", 12345, 1.0f );
+ doc.setField( "unknown field", 12345 );
DocumentBuilder.toDocument( doc, core.getLatestSchema() );
fail( "should throw an error" );
}
@@ -78,7 +63,7 @@ public class DocumentBuilderTest extends SolrTestCaseJ4 {
// make sure a null value is not indexed
SolrInputDocument doc = new SolrInputDocument();
- doc.addField( "name", null, 1.0f );
+ doc.addField( "name", null );
Document out = DocumentBuilder.toDocument( doc, core.getLatestSchema() );
assertNull( out.get( "name" ) );
}
@@ -90,8 +75,8 @@ public class DocumentBuilderTest extends SolrTestCaseJ4 {
// make sure a null value is not indexed
SolrInputDocument doc = new SolrInputDocument();
- doc.addField( "id", "123", 1.0f );
- doc.addField( "unknown", "something", 1.0f );
+ doc.addField( "id", "123" );
+ doc.addField( "unknown", "something" );
try {
DocumentBuilder.toDocument( doc, core.getLatestSchema() );
fail( "added an unknown field" );
@@ -102,7 +87,7 @@ public class DocumentBuilderTest extends SolrTestCaseJ4 {
doc.remove( "unknown" );
- doc.addField( "weight", "not a number", 1.0f );
+ doc.addField( "weight", "not a number" );
try {
DocumentBuilder.toDocument( doc, core.getLatestSchema() );
fail( "invalid 'float' field value" );
@@ -113,7 +98,7 @@ public class DocumentBuilderTest extends SolrTestCaseJ4 {
}
// now make sure it is OK
- doc.setField( "weight", "1.34", 1.0f );
+ doc.setField( "weight", "1.34" );
DocumentBuilder.toDocument( doc, core.getLatestSchema() );
}
@@ -123,95 +108,15 @@ public class DocumentBuilderTest extends SolrTestCaseJ4 {
// make sure a null value is not indexed
SolrInputDocument doc = new SolrInputDocument();
- doc.addField( "home", "2.2,3.3", 1.0f );
+ doc.addField( "home", "2.2,3.3" );
Document out = DocumentBuilder.toDocument( doc, core.getLatestSchema() );
assertNotNull( out.get( "home" ) );//contains the stored value and term vector, if there is one
assertNotNull( out.getField( "home_0" + FieldType.POLY_FIELD_SEPARATOR + "double" ) );
assertNotNull( out.getField( "home_1" + FieldType.POLY_FIELD_SEPARATOR + "double" ) );
}
- @Test
- public void testCopyFieldWithDocumentBoost() {
- SolrCore core = h.getCore();
- IndexSchema schema = core.getLatestSchema();
- assertFalse(schema.getField("title").omitNorms());
- assertTrue(schema.getField("title_stringNoNorms").omitNorms());
- SolrInputDocument doc = new SolrInputDocument();
- doc.setDocumentBoost(3f);
- doc.addField( "title", "mytitle");
- Document out = DocumentBuilder.toDocument( doc, schema );
- assertNotNull( out.get( "title_stringNoNorms" ) );
- assertTrue("title_stringNoNorms has the omitNorms attribute set to true, if the boost is different than 1.0, it will fail",1.0f == out.getField( "title_stringNoNorms" ).boost() );
- assertTrue("It is OK that title has a boost of 3",3.0f == out.getField( "title" ).boost() );
- }
-
-
- @Test
- public void testCopyFieldWithFieldBoost() {
- SolrCore core = h.getCore();
- IndexSchema schema = core.getLatestSchema();
- assertFalse(schema.getField("title").omitNorms());
- assertTrue(schema.getField("title_stringNoNorms").omitNorms());
- SolrInputDocument doc = new SolrInputDocument();
- doc.addField( "title", "mytitle", 3.0f );
- Document out = DocumentBuilder.toDocument( doc, schema );
- assertNotNull( out.get( "title_stringNoNorms" ) );
- assertTrue("title_stringNoNorms has the omitNorms attribute set to true, if the boost is different than 1.0, it will fail",1.0f == out.getField( "title_stringNoNorms" ).boost() );
- assertTrue("It is OK that title has a boost of 3",3.0f == out.getField( "title" ).boost() );
- }
-
- @Test
- public void testWithPolyFieldsAndFieldBoost() {
- SolrCore core = h.getCore();
- IndexSchema schema = core.getLatestSchema();
- assertFalse(schema.getField("store").omitNorms());
- assertTrue(schema.getField("store_0_coordinate").omitNorms());
- assertTrue(schema.getField("store_1_coordinate").omitNorms());
- assertFalse(schema.getField("amount").omitNorms());
- assertTrue(schema.getField("amount" + FieldType.POLY_FIELD_SEPARATOR + "_currency").omitNorms());
- assertTrue(schema.getField("amount" + FieldType.POLY_FIELD_SEPARATOR + "_amount_raw").omitNorms());
-
- SolrInputDocument doc = new SolrInputDocument();
- doc.addField( "store", "40.7143,-74.006", 3.0f );
- doc.addField( "amount", "10.5", 3.0f );
- Document out = DocumentBuilder.toDocument( doc, schema );
- assertNotNull( out.get( "store" ) );
- assertNotNull( out.get( "amount" ) );
- assertNotNull(out.getField("store_0_coordinate"));
- //NOTE: As the subtypes have omitNorm=true, they must have boost=1F, otherwise this is going to fail when adding the doc to Lucene.
- assertTrue(1f == out.getField("store_0_coordinate").boost());
- assertTrue(1f == out.getField("store_1_coordinate").boost());
- assertTrue(1f == out.getField("amount" + FieldType.POLY_FIELD_SEPARATOR + "_currency").boost());
- assertTrue(1f == out.getField("amount" + FieldType.POLY_FIELD_SEPARATOR + "_amount_raw").boost());
- }
-
- @Test
- public void testWithPolyFieldsAndDocumentBoost() {
- SolrCore core = h.getCore();
- IndexSchema schema = core.getLatestSchema();
- assertFalse(schema.getField("store").omitNorms());
- assertTrue(schema.getField("store_0_coordinate").omitNorms());
- assertTrue(schema.getField("store_1_coordinate").omitNorms());
- assertFalse(schema.getField("amount").omitNorms());
- assertTrue(schema.getField("amount" + FieldType.POLY_FIELD_SEPARATOR + "_currency").omitNorms());
- assertTrue(schema.getField("amount" + FieldType.POLY_FIELD_SEPARATOR + "_amount_raw").omitNorms());
-
- SolrInputDocument doc = new SolrInputDocument();
- doc.setDocumentBoost(3.0f);
- doc.addField( "store", "40.7143,-74.006");
- doc.addField( "amount", "10.5");
- Document out = DocumentBuilder.toDocument( doc, schema );
- assertNotNull( out.get( "store" ) );
- assertNotNull(out.getField("store_0_coordinate"));
- //NOTE: As the subtypes have omitNorm=true, they must have boost=1F, otherwise this is going to fail when adding the doc to Lucene.
- assertTrue(1f == out.getField("store_0_coordinate").boost());
- assertTrue(1f == out.getField("store_1_coordinate").boost());
- assertTrue(1f == out.getField("amount" + FieldType.POLY_FIELD_SEPARATOR + "_currency").boost());
- assertTrue(1f == out.getField("amount" + FieldType.POLY_FIELD_SEPARATOR + "_amount_raw").boost());
- }
-
/**
- * It's ok to boost a field if it has norms
+ * Even though boosts have been removed, we still support them for bw compat.
*/
public void testBoost() throws Exception {
XmlDoc xml = new XmlDoc();
@@ -222,192 +127,6 @@ public class DocumentBuilderTest extends SolrTestCaseJ4 {
assertNull(h.validateUpdate(add(xml, new String[0])));
}
- private void assertMultiValuedFieldAndDocBoosts(SolrInputField field) throws Exception {
- SolrCore core = h.getCore();
- IndexSchema schema = core.getLatestSchema();
- SolrInputDocument doc = new SolrInputDocument();
- doc.setDocumentBoost(3.0f);
- field.addValue( "summer time" , 1.0f );
- field.addValue( "in the city" , 5.0f ); // using boost
- field.addValue( "living is easy" , 1.0f );
- doc.put( field.getName(), field );
-
- Document out = DocumentBuilder.toDocument( doc, schema );
- IndexableField[] outF = out.getFields( field.getName() );
- assertEquals("wrong number of field values",
- 3, outF.length);
-
- // since Lucene no longer has native documnt boosts, we should find
- // the doc boost multiplied into the boost o nthe first field value
- // all other field values should be 1.0f
- // (lucene will multiply all of the field boosts later)
- assertEquals(15.0f, outF[0].boost(), 0.0f);
- assertEquals(1.0f, outF[1].boost(), 0.0f);
- assertEquals(1.0f, outF[2].boost(), 0.0f);
-
- }
-
- public void testMultiValuedFieldAndDocBoostsWithCopy() throws Exception {
- SolrCore core = h.getCore();
- IndexSchema schema = core.getLatestSchema();
- SolrInputField field = new SolrInputField( "foo_t" );
- List<CopyField> copyFields = schema.getCopyFieldsList(field.getName());
-
- assertNotNull( copyFields );
- assertFalse( copyFields.isEmpty() );
- assertMultiValuedFieldAndDocBoosts( field );
- }
-
- public void testMultiValuedFieldAndDocBoostsNoCopy() throws Exception {
- SolrCore core = h.getCore();
- IndexSchema schema = core.getLatestSchema();
- SolrInputField field = new SolrInputField( "t_foo" );
- List<CopyField> copyFields = schema.getCopyFieldsList(field.getName());
-
- assertTrue( copyFields == null || copyFields.isEmpty() );
- assertMultiValuedFieldAndDocBoosts( field );
- }
-
- public void testCopyFieldsAndFieldBoostsAndDocBoosts() throws Exception {
- SolrCore core = h.getCore();
- IndexSchema schema = core.getLatestSchema();
- SolrInputDocument doc = new SolrInputDocument();
-
- final float DOC_BOOST = 3.0F;
- doc.setDocumentBoost(DOC_BOOST);
- doc.addField("id", "42");
-
- SolrInputField inTitle = new SolrInputField( "title" );
- inTitle.addValue( "titleA" , 2.0F );
- inTitle.addValue( "titleB" , 7.0F );
- final float TITLE_BOOST = 2.0F * 7.0F;
- assertEquals(TITLE_BOOST, inTitle.getBoost(), 0.0F);
- doc.put( inTitle.getName(), inTitle );
-
- SolrInputField inFoo = new SolrInputField( "foo_t" );
- inFoo.addValue( "summer time" , 1.0F );
- inFoo.addValue( "in the city" , 5.0F );
- inFoo.addValue( "living is easy" , 11.0F );
- final float FOO_BOOST = 1.0F * 5.0F * 11.0F;
- assertEquals(FOO_BOOST, inFoo.getBoost(), 0.0F);
- doc.put( inFoo.getName(), inFoo );
-
- Document out = DocumentBuilder.toDocument( doc, schema );
-
- IndexableField[] outTitle = out.getFields( inTitle.getName() );
- assertEquals("wrong number of title values",
- 2, outTitle.length);
-
- IndexableField[] outNoNorms = out.getFields( "title_stringNoNorms" );
- assertEquals("wrong number of nonorms values",
- 2, outNoNorms.length);
-
- IndexableField[] outFoo = out.getFields( inFoo.getName() );
- assertEquals("wrong number of foo values",
- 3, outFoo.length);
-
- IndexableField[] outText = out.getFields( "text" );
- assertEquals("wrong number of text values",
- 5, outText.length);
-
- // since Lucene no longer has native document boosts, we should find
- // the doc boost multiplied into the boost on the first field value
- // of each field. All other field values should be 1.0f
- // (lucene will multiply all of the field value boosts later)
- assertEquals(TITLE_BOOST * DOC_BOOST, outTitle[0].boost(), 0.0F);
- assertEquals(1.0F, outTitle[1].boost(), 0.0F);
- //
- assertEquals(FOO_BOOST * DOC_BOOST, outFoo[0].boost(), 0.0F);
- assertEquals(1.0F, outFoo[1].boost(), 0.0F);
- assertEquals(1.0F, outFoo[2].boost(), 0.0F);
- //
- assertEquals(TITLE_BOOST * DOC_BOOST, outText[0].boost(), 0.0F);
- assertEquals(1.0F, outText[1].boost(), 0.0F);
- assertEquals(FOO_BOOST, outText[2].boost(), 0.0F);
- assertEquals(1.0F, outText[3].boost(), 0.0F);
- assertEquals(1.0F, outText[4].boost(), 0.0F);
-
- // copyField dest with no norms should not have received any boost
- assertEquals(1.0F, outNoNorms[0].boost(), 0.0F);
- assertEquals(1.0F, outNoNorms[1].boost(), 0.0F);
-
- // now index that SolrInputDocument to check the computed norms
-
- assertU(adoc(doc));
- assertU(commit());
-
- SolrQueryRequest req = req("q", "id:42");
- try {
- // very hack-ish
-
- SolrQueryResponse rsp = new SolrQueryResponse();
- core.execute(core.getRequestHandler(req.getParams().get(CommonParams.QT)), req, rsp);
-
- DocList dl = ((ResultContext) rsp.getResponse()).getDocList();
- assertTrue("can't find the doc we just added", 1 == dl.size());
- int docid = dl.iterator().nextDoc();
-
- SolrIndexSearcher searcher = req.getSearcher();
- LeafReader reader = SlowCompositeReaderWrapper.wrap(searcher.getTopReaderContext().reader());
-
- assertTrue("similarity doesn't extend ClassicSimilarity, " +
- "config or defaults have changed since test was written",
- searcher.getSimilarity(true) instanceof ClassicSimilarity);
-
- ClassicSimilarity sim = (ClassicSimilarity) searcher.getSimilarity(true);
-
- NumericDocValues titleNorms = reader.getNormValues("title");
- NumericDocValues fooNorms = reader.getNormValues("foo_t");
- NumericDocValues textNorms = reader.getNormValues("text");
-
- assertEquals(docid, titleNorms.advance(docid));
- assertEquals(expectedNorm(sim, 2, TITLE_BOOST * DOC_BOOST),
- titleNorms.longValue());
-
- assertEquals(docid, fooNorms.advance(docid));
- assertEquals(expectedNorm(sim, 8-3, FOO_BOOST * DOC_BOOST),
- fooNorms.longValue());
-
- assertEquals(docid, textNorms.advance(docid));
- assertEquals(expectedNorm(sim, 2 + 8-3,
- TITLE_BOOST * FOO_BOOST * DOC_BOOST),
- textNorms.longValue());
-
- } finally {
- req.close();
- }
- }
-
- /**
- * Given a length, and boost returns the expected encoded norm
- */
- private static byte expectedNorm(final ClassicSimilarity sim,
- final int length, final float boost) {
- return (byte) sim.encodeNormValue(boost / ((float) Math.sqrt(length)));
- }
-
-
- public void testBoostOmitNorms() throws Exception {
- XmlDoc xml = new XmlDoc();
- // explicitly boosting a field if that omits norms is not ok
- xml.xml = "<doc>"
- + "<field name=\"id\">ignore_exception</field>"
- + "<field name=\"title_stringNoNorms\" boost=\"3.0\">mytitle</field>"
- + "</doc>";
- try {
- assertNull(h.validateUpdate(add(xml, new String[0])));
- fail("didn't get expected exception for boosting omit norms field");
- } catch (SolrException expected) {
- // expected exception
- }
- // boosting a field that is copied to another field that omits norms is ok
- xml.xml = "<doc>"
- + "<field name=\"id\">42</field>"
- + "<field name=\"title\" boost=\"3.0\">mytitle</field>"
- + "</doc>";
- assertNull(h.validateUpdate(add(xml, new String[0])));
- }
-
/**
* It's ok to supply a document boost even if a field omits norms
*/
@@ -467,15 +186,6 @@ public class DocumentBuilderTest extends SolrTestCaseJ4 {
assertTrue(compareSolrInputDocument(doc1, doc2));
- doc1.setDocumentBoost(1.1f);
- assertFalse(compareSolrInputDocument(doc1, doc2));
-
- doc2.setDocumentBoost(1.1f);
- assertTrue(compareSolrInputDocument(doc1, doc2));
-
- doc2.setDocumentBoost(20f);
- assertFalse(compareSolrInputDocument(doc1, doc2));
-
doc1 = new SolrInputDocument();
doc1.addField("foo", randomString);
@@ -503,19 +213,12 @@ public class DocumentBuilderTest extends SolrTestCaseJ4 {
int val = random().nextInt();
SolrInputField sif1 = new SolrInputField(randomString);
- sif1.setValue(val, 1.0f);
+ sif1.setValue(val);
SolrInputField sif2 = new SolrInputField(randomString);
- sif2.setValue(val, 1.0f);
-
- assertTrue(assertSolrInputFieldEquals(sif1, sif2));
+ sif2.setValue(val);
- sif1.setBoost(2.1f);
- sif2.setBoost(2.1f);
assertTrue(assertSolrInputFieldEquals(sif1, sif2));
- sif2.setBoost(2.0f);
- assertFalse(assertSolrInputFieldEquals(sif1, sif2));
-
sif2.setName("foo");
assertFalse(assertSolrInputFieldEquals(sif1, sif2));
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8ed2b764/solr/core/src/test/org/apache/solr/update/processor/CloneFieldUpdateProcessorFactoryTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/update/processor/CloneFieldUpdateProcessorFactoryTest.java b/solr/core/src/test/org/apache/solr/update/processor/CloneFieldUpdateProcessorFactoryTest.java
index c01c319..051cad1 100644
--- a/solr/core/src/test/org/apache/solr/update/processor/CloneFieldUpdateProcessorFactoryTest.java
+++ b/solr/core/src/test/org/apache/solr/update/processor/CloneFieldUpdateProcessorFactoryTest.java
@@ -177,7 +177,7 @@ public class CloneFieldUpdateProcessorFactoryTest extends UpdateProcessorTestBas
// append to existing values, preserve boost
d = processAdd(chain,
doc(f("id", "1111"),
- field("dest_s", 2.3f, "orig1", "orig2"),
+ field("dest_s", "orig1", "orig2"),
f("source0_s", "NOT COPIED"),
f("source1_s", "123456789", "", 42, "abcd")));
assertNotNull(chain, d);
@@ -187,8 +187,6 @@ public class CloneFieldUpdateProcessorFactoryTest extends UpdateProcessorTestBas
assertEquals(chain,
Arrays.asList("orig1", "orig2", "123456789", "", 42, "abcd"),
d.getFieldValues("dest_s"));
- assertEquals(chain + ": dest boost changed",
- 2.3f, d.getField("dest_s").getBoost(), 0.0f);
}
// should be equivalent for any chain matching source1_s and source2_s (but not source0_s)
@@ -213,10 +211,10 @@ public class CloneFieldUpdateProcessorFactoryTest extends UpdateProcessorTestBas
Arrays.asList("123456789", "", 42, "abcd", "xxx", 999),
d.getFieldValues("dest_s"));
- // append to existing values, preserve boost
+ // append to existing values
d = processAdd(chain,
doc(f("id", "1111"),
- field("dest_s", 2.3f, "orig1", "orig2"),
+ field("dest_s", "orig1", "orig2"),
f("source0_s", "NOT COPIED"),
f("source1_s", "123456789", "", 42, "abcd"),
f("source2_s", "xxx", 999)));
@@ -232,8 +230,6 @@ public class CloneFieldUpdateProcessorFactoryTest extends UpdateProcessorTestBas
"123456789", "", 42, "abcd",
"xxx", 999),
d.getFieldValues("dest_s"));
- assertEquals(chain + ": dest boost changed",
- 2.3f, d.getField("dest_s").getBoost(), 0.0f);
}
// any chain that copies source1_s to dest_s should be equivalent for these assertions
@@ -258,7 +254,7 @@ public class CloneFieldUpdateProcessorFactoryTest extends UpdateProcessorTestBas
// append to existing values, preserve boost
d = processAdd(chain,
doc(f("id", "1111"),
- field("dest_s", 2.3f, "orig1", "orig2"),
+ field("dest_s", "orig1", "orig2"),
f("source1_s", "123456789", "", 42, "abcd")));
assertNotNull(chain, d);
assertEquals(chain,
@@ -267,8 +263,6 @@ public class CloneFieldUpdateProcessorFactoryTest extends UpdateProcessorTestBas
assertEquals(chain,
Arrays.asList("orig1", "orig2", "123456789", "", 42, "abcd"),
d.getFieldValues("dest_s"));
- assertEquals(chain + ": dest boost changed",
- 2.3f, d.getField("dest_s").getBoost(), 0.0f);
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8ed2b764/solr/core/src/test/org/apache/solr/update/processor/DefaultValueUpdateProcessorTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/update/processor/DefaultValueUpdateProcessorTest.java b/solr/core/src/test/org/apache/solr/update/processor/DefaultValueUpdateProcessorTest.java
index c90a727..e328267 100644
--- a/solr/core/src/test/org/apache/solr/update/processor/DefaultValueUpdateProcessorTest.java
+++ b/solr/core/src/test/org/apache/solr/update/processor/DefaultValueUpdateProcessorTest.java
@@ -104,12 +104,11 @@ public class DefaultValueUpdateProcessorTest extends SolrTestCaseJ4 {
/**
* Convenience method for building up SolrInputFields
*/
- SolrInputField field(String name, float boost, Object... values) {
+ SolrInputField field(String name, Object... values) {
SolrInputField f = new SolrInputField(name);
for (Object v : values) {
- f.addValue(v, 1.0F);
+ f.addValue(v);
}
- f.setBoost(boost);
return f;
}
@@ -117,7 +116,7 @@ public class DefaultValueUpdateProcessorTest extends SolrTestCaseJ4 {
* Convenience method for building up SolrInputFields with default boost
*/
SolrInputField f(String name, Object... values) {
- return field(name, 1.0F, values);
+ return field(name, values);
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8ed2b764/solr/core/src/test/org/apache/solr/update/processor/FieldMutatingUpdateProcessorTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/update/processor/FieldMutatingUpdateProcessorTest.java b/solr/core/src/test/org/apache/solr/update/processor/FieldMutatingUpdateProcessorTest.java
index ecfe772..55fa5bd 100644
--- a/solr/core/src/test/org/apache/solr/update/processor/FieldMutatingUpdateProcessorTest.java
+++ b/solr/core/src/test/org/apache/solr/update/processor/FieldMutatingUpdateProcessorTest.java
@@ -75,7 +75,7 @@ public class FieldMutatingUpdateProcessorTest extends UpdateProcessorTestBase {
f("name", " Hoss ", new StringBuilder(" Man")),
f("foo_t", " some text ", "other Text\t"),
f("foo_d", new Integer(42)),
- field("foo_s", 5.0F, " string ")));
+ field("foo_s", " string ")));
assertNotNull(d);
@@ -89,8 +89,6 @@ public class FieldMutatingUpdateProcessorTest extends UpdateProcessorTestBase {
// slightly more interesting
assertEquals("processor borked non string value",
new Integer(42), d.getFieldValue("foo_d"));
- assertEquals("wrong boost",
- 5.0F, d.getField("foo_s").getBoost(), 0.0F);
}
public void testUniqValues() throws Exception {
@@ -448,7 +446,7 @@ public class FieldMutatingUpdateProcessorTest extends UpdateProcessorTestBase {
special = new SolrInputField("foo_s");
special.setValue(new TreeSet<>
- (Arrays.asList("ggg", "first", "last", "hhh")), 1.2F);
+ (Arrays.asList("ggg", "first", "last", "hhh")));
d = processAdd("last-value",
doc(f("id", "1111"),
@@ -461,7 +459,7 @@ public class FieldMutatingUpdateProcessorTest extends UpdateProcessorTestBase {
// test something that's definitely a List
special = new SolrInputField("foo_s");
- special.setValue(Arrays.asList("first", "ggg", "hhh", "last"), 1.2F);
+ special.setValue(Arrays.asList("first", "ggg", "hhh", "last"));
d = processAdd("last-value",
doc(f("id", "1111"),
@@ -476,7 +474,7 @@ public class FieldMutatingUpdateProcessorTest extends UpdateProcessorTestBase {
special = new SolrInputField("foo_s");
special.setValue(new LinkedHashSet<>
- (Arrays.asList("first", "ggg", "hhh", "last")), 1.2F);
+ (Arrays.asList("first", "ggg", "hhh", "last")));
d = processAdd("last-value",
doc(f("id", "1111"),
@@ -819,7 +817,7 @@ public class FieldMutatingUpdateProcessorTest extends UpdateProcessorTestBase {
doc(f("id", "1111"),
f("foo_t", "string1", "string2"),
f("foo_d", new Integer(42)),
- field("foo_s", 3.0F, "string3", "string4")));
+ field("foo_s", "string3", "string4")));
assertNotNull(d);
@@ -830,8 +828,6 @@ public class FieldMutatingUpdateProcessorTest extends UpdateProcessorTestBase {
// slightly more interesting
assertEquals("processor borked non string value",
new Integer(42), d.getFieldValue("foo_d"));
- assertEquals("wrong boost",
- 3.0F, d.getField("foo_s").getBoost(), 0.0F);
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8ed2b764/solr/core/src/test/org/apache/solr/update/processor/TolerantUpdateProcessorTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/update/processor/TolerantUpdateProcessorTest.java b/solr/core/src/test/org/apache/solr/update/processor/TolerantUpdateProcessorTest.java
index f4ab1fa..6e7584f 100644
--- a/solr/core/src/test/org/apache/solr/update/processor/TolerantUpdateProcessorTest.java
+++ b/solr/core/src/test/org/apache/solr/update/processor/TolerantUpdateProcessorTest.java
@@ -81,9 +81,9 @@ public class TolerantUpdateProcessorTest extends UpdateProcessorTestBase {
badIds = new String[10];
for(int i = 0; i < 10;i++) {
// a valid document
- docs.add(doc(field("id", 1f, String.valueOf(2*i)), field("weight", 1f, i)));
+ docs.add(doc(field("id", String.valueOf(2*i)), field("weight", i)));
// ... and an invalid one
- docs.add(doc(field("id", 1f, String.valueOf(2*i+1)), field("weight", 1f, "b")));
+ docs.add(doc(field("id", String.valueOf(2*i+1)), field("weight", "b")));
badIds[i] = String.valueOf(2*i+1);
}
}
@@ -119,10 +119,10 @@ public class TolerantUpdateProcessorTest extends UpdateProcessorTestBase {
@Test
public void testValidAdds() throws IOException {
- SolrInputDocument validDoc = doc(field("id", 1f, "1"), field("text", 1f, "the quick brown fox"));
+ SolrInputDocument validDoc = doc(field("id", "1"), field("text", "the quick brown fox"));
add("tolerant-chain-max-errors-10", null, validDoc);
- validDoc = doc(field("id", 1f, "2"), field("text", 1f, "the quick brown fox"));
+ validDoc = doc(field("id", "2"), field("text", "the quick brown fox"));
add("tolerant-chain-max-errors-not-set", null, validDoc);
assertU(commit());
@@ -136,7 +136,7 @@ public class TolerantUpdateProcessorTest extends UpdateProcessorTestBase {
@Test
public void testInvalidAdds() throws IOException {
- SolrInputDocument invalidDoc = doc(field("text", 1f, "the quick brown fox")); //no id
+ SolrInputDocument invalidDoc = doc(field("text", "the quick brown fox")); //no id
try {
// This doc should fail without being tolerant
add("not-tolerant", null, invalidDoc);
@@ -148,7 +148,7 @@ public class TolerantUpdateProcessorTest extends UpdateProcessorTestBase {
assertAddsSucceedWithErrors("tolerant-chain-max-errors-10", Arrays.asList(new SolrInputDocument[]{invalidDoc}), null, "(unknown)");
//a valid doc
- SolrInputDocument validDoc = doc(field("id", 1f, "1"), field("text", 1f, "the quick brown fox"));
+ SolrInputDocument validDoc = doc(field("id", "1"), field("text", "the quick brown fox"));
try {
// This batch should fail without being tolerant
@@ -171,8 +171,8 @@ public class TolerantUpdateProcessorTest extends UpdateProcessorTestBase {
assertQ(req("q","id:1")
,"//result[@numFound='1']");
- invalidDoc = doc(field("id", 1f, "2"), field("weight", 1f, "aaa"));
- validDoc = doc(field("id", 1f, "3"), field("weight", 1f, "3"));
+ invalidDoc = doc(field("id", "2"), field("weight", "aaa"));
+ validDoc = doc(field("id", "3"), field("weight", "3"));
try {
// This batch should fail without being tolerant
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8ed2b764/solr/core/src/test/org/apache/solr/update/processor/UUIDUpdateProcessorFallbackTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/update/processor/UUIDUpdateProcessorFallbackTest.java b/solr/core/src/test/org/apache/solr/update/processor/UUIDUpdateProcessorFallbackTest.java
index bca2d30..2b10953 100644
--- a/solr/core/src/test/org/apache/solr/update/processor/UUIDUpdateProcessorFallbackTest.java
+++ b/solr/core/src/test/org/apache/solr/update/processor/UUIDUpdateProcessorFallbackTest.java
@@ -106,9 +106,8 @@ public class UUIDUpdateProcessorFallbackTest extends SolrTestCaseJ4 {
SolrInputField field(String name, float boost, Object... values) {
SolrInputField f = new SolrInputField(name);
for (Object v : values) {
- f.addValue(v, 1.0F);
+ f.addValue(v);
}
- f.setBoost(boost);
return f;
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8ed2b764/solr/core/src/test/org/apache/solr/update/processor/UpdateProcessorTestBase.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/update/processor/UpdateProcessorTestBase.java b/solr/core/src/test/org/apache/solr/update/processor/UpdateProcessorTestBase.java
index e069ee2..d3aa979 100644
--- a/solr/core/src/test/org/apache/solr/update/processor/UpdateProcessorTestBase.java
+++ b/solr/core/src/test/org/apache/solr/update/processor/UpdateProcessorTestBase.java
@@ -151,12 +151,11 @@ public class UpdateProcessorTestBase extends SolrTestCaseJ4 {
/**
* Convenience method for building up SolrInputFields
*/
- final SolrInputField field(String name, float boost, Object... values) {
+ final SolrInputField field(String name, Object... values) {
SolrInputField f = new SolrInputField(name);
for (Object v : values) {
- f.addValue(v, 1.0F);
+ f.addValue(v);
}
- f.setBoost(boost);
return f;
}
@@ -164,6 +163,6 @@ public class UpdateProcessorTestBase extends SolrTestCaseJ4 {
* Convenience method for building up SolrInputFields with default boost
*/
final SolrInputField f(String name, Object... values) {
- return field(name, 1.0F, values);
+ return field(name, values);
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8ed2b764/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java b/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java
index 9550a41..e2e65bb 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java
@@ -86,13 +86,13 @@ public class DocumentObjectBinder {
Map<String, Object> mapValue = (Map<String, Object>) field.get(obj);
for (Map.Entry<String, Object> e : mapValue.entrySet()) {
- doc.setField(e.getKey(), e.getValue(), 1.0f);
+ doc.setField(e.getKey(), e.getValue());
}
} else {
if (field.child != null) {
addChild(obj, field, doc);
} else {
- doc.setField(field.name, field.get(obj), 1.0f);
+ doc.setField(field.name, field.get(obj));
}
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8ed2b764/solr/solrj/src/java/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java b/solr/solrj/src/java/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java
index 47521de..7776a13 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java
@@ -19,12 +19,14 @@ package org.apache.solr.client.solrj.request;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.params.ModifiableSolrParams;
@@ -32,6 +34,8 @@ import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.DataInputInputStream;
import org.apache.solr.common.util.JavaBinCodec;
import org.apache.solr.common.util.NamedList;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Provides methods for marshalling an UpdateRequest to a NamedList which can be serialized in the javabin format and
@@ -43,6 +47,9 @@ import org.apache.solr.common.util.NamedList;
*/
public class JavaBinUpdateRequestCodec {
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static final AtomicBoolean WARNED_ABOUT_INDEX_TIME_BOOSTS = new AtomicBoolean();
+
/**
* Converts an UpdateRequest to a NamedList which can be serialized to the given OutputStream in the javabin format
*
@@ -243,11 +250,27 @@ public class JavaBinUpdateRequestCodec {
for (int i = 0; i < namedList.size(); i++) {
NamedList nl = namedList.get(i);
if (i == 0) {
- doc.setDocumentBoost(nl.getVal(0) == null ? 1.0f : (Float) nl.getVal(0));
+ Float boost = (Float) nl.getVal(0);
+ if (boost != null && boost.floatValue() != 1f) {
+ String message = "Ignoring document boost: " + boost + " as index-time boosts are not supported anymore";
+ if (WARNED_ABOUT_INDEX_TIME_BOOSTS.compareAndSet(false, true)) {
+ log.warn(message);
+ } else {
+ log.debug(message);
+ }
+ }
} else {
+ Float boost = (Float) nl.getVal(2);
+ if (boost != null && boost.floatValue() != 1f) {
+ String message = "Ignoring field boost: " + boost + " as index-time boosts are not supported anymore";
+ if (WARNED_ABOUT_INDEX_TIME_BOOSTS.compareAndSet(false, true)) {
+ log.warn(message);
+ } else {
+ log.debug(message);
+ }
+ }
doc.addField((String) nl.getVal(0),
- nl.getVal(1),
- nl.getVal(2) == null ? 1.0f : (Float) nl.getVal(2));
+ nl.getVal(1));
}
}
return doc;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8ed2b764/solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java b/solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java
index beed40e..c5595b1 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java
@@ -64,10 +64,9 @@ public class ClientUtils
public static void writeXML( SolrInputDocument doc, Writer writer ) throws IOException
{
- writer.write("<doc boost=\""+doc.getDocumentBoost()+"\">");
+ writer.write("<doc>");
for( SolrInputField field : doc ) {
- float boost = field.getBoost();
String name = field.getName();
for( Object v : field ) {
@@ -81,19 +80,14 @@ public class ClientUtils
if (v instanceof Collection) {
Collection values = (Collection) v;
for (Object value : values) {
- writeVal(writer, boost, name, value, update);
- boost = 1.0f;
+ writeVal(writer, name, value, update);
}
} else {
- writeVal(writer, boost, name, v, update);
- boost = 1.0f;
+ writeVal(writer, name, v, update);
}
}
} else {
- writeVal(writer, boost, name, v, update);
- // only write the boost for the first multi-valued field
- // otherwise, the used boost is the product of all the boost values
- boost = 1.0f;
+ writeVal(writer, name, v, update);
}
}
}
@@ -107,7 +101,7 @@ public class ClientUtils
writer.write("</doc>");
}
- private static void writeVal(Writer writer, float boost, String name, Object v, String update) throws IOException {
+ private static void writeVal(Writer writer, String name, Object v, String update) throws IOException {
if (v instanceof Date) {
v = ((Date)v).toInstant().toString();
} else if (v instanceof byte[]) {
@@ -119,20 +113,14 @@ public class ClientUtils
}
if (update == null) {
- if( boost != 1.0f ) {
- XML.writeXML(writer, "field", v.toString(), "name", name, "boost", boost);
- } else if (v != null) {
+ if (v != null) {
XML.writeXML(writer, "field", v.toString(), "name", name );
}
} else {
- if( boost != 1.0f ) {
- XML.writeXML(writer, "field", v.toString(), "name", name, "boost", boost, "update", update);
- } else {
- if (v == null) {
- XML.writeXML(writer, "field", null, "name", name, "update", update, "null", true);
- } else {
- XML.writeXML(writer, "field", v.toString(), "name", name, "update", update);
- }
+ if (v == null) {
+ XML.writeXML(writer, "field", null, "name", name, "update", update, "null", true);
+ } else {
+ XML.writeXML(writer, "field", v.toString(), "name", name, "update", update);
}
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8ed2b764/solr/solrj/src/java/org/apache/solr/common/SolrInputDocument.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/common/SolrInputDocument.java b/solr/solrj/src/java/org/apache/solr/common/SolrInputDocument.java
index 3d3c060..c8451aa 100644
--- a/solr/solrj/src/java/org/apache/solr/common/SolrInputDocument.java
+++ b/solr/solrj/src/java/org/apache/solr/common/SolrInputDocument.java
@@ -35,7 +35,6 @@ import java.util.Set;
public class SolrInputDocument extends SolrDocumentBase<SolrInputField, SolrInputDocument> implements Iterable<SolrInputField>
{
private final Map<String,SolrInputField> _fields;
- private float _documentBoost = 1.0f;
private List<SolrInputDocument> _childDocuments;
public SolrInputDocument(String... fields) {
@@ -74,11 +73,16 @@ public class SolrInputDocument extends SolrDocumentBase<SolrInputField, SolrInpu
*
* @param name Name of the field, should match one of the field names defined under "fields" tag in schema.xml.
* @param value Value of the field, should be of same class type as defined by "type" attribute of the corresponding field in schema.xml.
- * @see #addField(String, Object, float)
*/
public void addField(String name, Object value)
{
- addField(name, value, 1.0f );
+ SolrInputField field = _fields.get( name );
+ if( field == null || field.value == null ) {
+ setField(name, value);
+ }
+ else {
+ field.addValue( value );
+ }
}
/** Get the first value for a field.
@@ -122,44 +126,14 @@ public class SolrInputDocument extends SolrDocumentBase<SolrInputField, SolrInpu
/** Set a field with implied null value for boost.
*
- * @see #setField(String, Object, float)
* @param name name of the field to set
* @param value value of the field
*/
- public void setField(String name, Object value)
- {
- setField(name, value, 1.0f );
- }
-
- public void setField(String name, Object value, float boost )
+ public void setField(String name, Object value )
{
SolrInputField field = new SolrInputField( name );
_fields.put( name, field );
- field.setValue( value, boost );
- }
-
- /**
- * Adds a field with the given name, value and boost. If a field with the
- * name already exists, then the given value is appended to the value of that
- * field, with the new boost. If the value is a collection, then each of its
- * values will be added to the field.
- *
- * The class type of value and the name parameter should match schema.xml.
- * schema.xml can be found in conf directory under the solr home by default.
- *
- * @param name Name of the field, should match one of the field names defined under "fields" tag in schema.xml.
- * @param value Value of the field, should be of same class type as defined by "type" attribute of the corresponding field in schema.xml.
- * @param boost Boost value for the field
- */
- public void addField(String name, Object value, float boost )
- {
- SolrInputField field = _fields.get( name );
- if( field == null || field.value == null ) {
- setField(name, value, boost);
- }
- else {
- field.addValue( value, boost );
- }
+ field.setValue( value );
}
/**
@@ -187,14 +161,6 @@ public class SolrInputDocument extends SolrDocumentBase<SolrInputField, SolrInpu
return _fields.values().iterator();
}
- public float getDocumentBoost() {
- return _documentBoost;
- }
-
- public void setDocumentBoost(float documentBoost) {
- _documentBoost = documentBoost;
- }
-
@Override
public String toString()
{
@@ -209,7 +175,6 @@ public class SolrInputDocument extends SolrDocumentBase<SolrInputField, SolrInpu
for (Map.Entry<String,SolrInputField> fieldEntry : entries) {
clone._fields.put(fieldEntry.getKey(), fieldEntry.getValue().deepCopy());
}
- clone._documentBoost = _documentBoost;
if (_childDocuments != null) {
clone._childDocuments = new ArrayList<>(_childDocuments.size());
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8ed2b764/solr/solrj/src/java/org/apache/solr/common/SolrInputField.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/common/SolrInputField.java b/solr/solrj/src/java/org/apache/solr/common/SolrInputField.java
index 261b326..94e98de 100644
--- a/solr/solrj/src/java/org/apache/solr/common/SolrInputField.java
+++ b/solr/solrj/src/java/org/apache/solr/common/SolrInputField.java
@@ -29,7 +29,6 @@ public class SolrInputField implements Iterable<Object>, Serializable
{
String name;
Object value = null;
- float boost = 1.0f;
public SolrInputField( String n )
{
@@ -44,9 +43,7 @@ public class SolrInputField implements Iterable<Object>, Serializable
* a collection is given, then that collection will be used as the backing
* collection for the values.
*/
- public void setValue(Object v, float b) {
- boost = b;
-
+ public void setValue(Object v) {
if( v instanceof Object[] ) {
Object[] arr = (Object[])v;
Collection<Object> c = new ArrayList<>( arr.length );
@@ -65,27 +62,21 @@ public class SolrInputField implements Iterable<Object>, Serializable
* will be added individually.
*/
@SuppressWarnings("unchecked")
- public void addValue(Object v, float b) {
+ public void addValue(Object v) {
if( value == null ) {
if ( v instanceof Collection ) {
Collection<Object> c = new ArrayList<>( 3 );
for ( Object o : (Collection<Object>)v ) {
c.add( o );
}
- setValue(c, b);
+ setValue(c);
} else {
- setValue(v, b);
+ setValue(v);
}
return;
}
- // The lucene API and solr XML field specification make it possible to set boosts
- // on multi-value fields even though lucene indexing does not support this.
- // To keep behavior consistent with what happens in the lucene index, we accumulate
- // the product of all boosts specified for this field.
- boost *= b;
-
Collection<Object> vals = null;
if( value instanceof Collection ) {
vals = (Collection<Object>)value;
@@ -164,14 +155,6 @@ public class SolrInputField implements Iterable<Object>, Serializable
//---------------------------------------------------------------
//---------------------------------------------------------------
-
- public float getBoost() {
- return boost;
- }
-
- public void setBoost(float boost) {
- this.boost = boost;
- }
public String getName() {
return name;
@@ -211,12 +194,11 @@ public class SolrInputField implements Iterable<Object>, Serializable
@Override
public String toString()
{
- return name + ((boost == 1.0) ? "=" : ("("+boost+")=")) + value;
+ return name + "=" + value;
}
public SolrInputField deepCopy() {
SolrInputField clone = new SolrInputField(name);
- clone.boost = boost;
// We can't clone here, so we rely on simple primitives
if (value instanceof Collection) {
Collection<Object> values = (Collection<Object>) value;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8ed2b764/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java b/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java
index 7e0cac6..def3571 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java
@@ -19,6 +19,7 @@ package org.apache.solr.common.util;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.lang.invoke.MethodHandles;
import java.nio.ByteBuffer;
import java.nio.file.Path;
import java.util.ArrayList;
@@ -31,6 +32,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.solr.common.EnumFieldValue;
import org.apache.solr.common.IteratorWriter;
@@ -43,6 +45,8 @@ import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.SolrInputField;
import org.noggit.CharArr;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Defines a space-efficient serialization/deserialization format for transferring data.
@@ -61,6 +65,9 @@ import org.noggit.CharArr;
*/
public class JavaBinCodec implements PushWriter {
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static final AtomicBoolean WARNED_ABOUT_INDEX_TIME_BOOSTS = new AtomicBoolean();
+
public static final byte
NULL = 0,
BOOL_TRUE = 1,
@@ -555,14 +562,28 @@ public class JavaBinCodec implements PushWriter {
public SolrInputDocument readSolrInputDocument(DataInputInputStream dis) throws IOException {
int sz = readVInt(dis);
float docBoost = (Float)readVal(dis);
+ if (docBoost != 1f) {
+ String message = "Ignoring document boost: " + docBoost + " as index-time boosts are not supported anymore";
+ if (WARNED_ABOUT_INDEX_TIME_BOOSTS.compareAndSet(false, true)) {
+ log.warn(message);
+ } else {
+ log.debug(message);
+ }
+ }
SolrInputDocument sdoc = new SolrInputDocument(new LinkedHashMap<>(sz));
- sdoc.setDocumentBoost(docBoost);
for (int i = 0; i < sz; i++) {
- float boost = 1.0f;
String fieldName;
Object obj = readVal(dis); // could be a boost, a field name, or a child document
if (obj instanceof Float) {
- boost = (Float)obj;
+ float boost = (Float)obj;
+ if (boost != 1f) {
+ String message = "Ignoring field boost: " + boost + " as index-time boosts are not supported anymore";
+ if (WARNED_ABOUT_INDEX_TIME_BOOSTS.compareAndSet(false, true)) {
+ log.warn(message);
+ } else {
+ log.debug(message);
+ }
+ }
fieldName = (String)readVal(dis);
} else if (obj instanceof SolrInputDocument) {
sdoc.addChildDocument((SolrInputDocument)obj);
@@ -571,7 +592,7 @@ public class JavaBinCodec implements PushWriter {
fieldName = (String)obj;
}
Object fieldVal = readVal(dis);
- sdoc.setField(fieldName, fieldVal, boost);
+ sdoc.setField(fieldName, fieldVal);
}
return sdoc;
}
@@ -580,11 +601,8 @@ public class JavaBinCodec implements PushWriter {
List<SolrInputDocument> children = sdoc.getChildDocuments();
int sz = sdoc.size() + (children==null ? 0 : children.size());
writeTag(SOLRINPUTDOC, sz);
- writeFloat(sdoc.getDocumentBoost());
+ writeFloat(1f); // document boost
for (SolrInputField inputField : sdoc.values()) {
- if (inputField.getBoost() != 1.0f) {
- writeFloat(inputField.getBoost());
- }
writeExternString(inputField.getName());
writeVal(inputField.getValue());
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8ed2b764/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java
index d25280d..b1e7285 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java
@@ -100,8 +100,8 @@ abstract public class SolrExampleTests extends SolrExampleTestsBase
// Now add something...
SolrInputDocument doc = new SolrInputDocument();
String docID = "1112211111";
- doc.addField( "id", docID, 1.0f );
- doc.addField( "name", "my name!", 1.0f );
+ doc.addField( "id", docID );
+ doc.addField( "name", "my name!" );
Assert.assertEquals( null, doc.getField("foo") );
Assert.assertTrue(doc.getField("name").getValue() != null );
@@ -127,28 +127,28 @@ abstract public class SolrExampleTests extends SolrExampleTestsBase
// Now add a few docs for facet testing...
List<SolrInputDocument> docs = new ArrayList<>();
SolrInputDocument doc2 = new SolrInputDocument();
- doc2.addField( "id", "2", 1.0f );
- doc2.addField( "inStock", true, 1.0f );
- doc2.addField( "price", 2, 1.0f );
- doc2.addField( "timestamp_dt", new java.util.Date(), 1.0f );
+ doc2.addField( "id", "2" );
+ doc2.addField( "inStock", true );
+ doc2.addField( "price", 2 );
+ doc2.addField( "timestamp_dt", new java.util.Date() );
docs.add(doc2);
SolrInputDocument doc3 = new SolrInputDocument();
- doc3.addField( "id", "3", 1.0f );
- doc3.addField( "inStock", false, 1.0f );
- doc3.addField( "price", 3, 1.0f );
- doc3.addField( "timestamp_dt", new java.util.Date(), 1.0f );
+ doc3.addField( "id", "3" );
+ doc3.addField( "inStock", false );
+ doc3.addField( "price", 3 );
+ doc3.addField( "timestamp_dt", new java.util.Date() );
docs.add(doc3);
SolrInputDocument doc4 = new SolrInputDocument();
- doc4.addField( "id", "4", 1.0f );
- doc4.addField( "inStock", true, 1.0f );
- doc4.addField( "price", 4, 1.0f );
- doc4.addField( "timestamp_dt", new java.util.Date(), 1.0f );
+ doc4.addField( "id", "4" );
+ doc4.addField( "inStock", true );
+ doc4.addField( "price", 4 );
+ doc4.addField( "timestamp_dt", new java.util.Date() );
docs.add(doc4);
SolrInputDocument doc5 = new SolrInputDocument();
- doc5.addField( "id", "5", 1.0f );
- doc5.addField( "inStock", false, 1.0f );
- doc5.addField( "price", 5, 1.0f );
- doc5.addField( "timestamp_dt", new java.util.Date(), 1.0f );
+ doc5.addField( "id", "5" );
+ doc5.addField( "inStock", false );
+ doc5.addField( "price", 5 );
+ doc5.addField( "timestamp_dt", new java.util.Date() );
docs.add(doc5);
upres = client.add( docs );
@@ -247,13 +247,13 @@ abstract public class SolrExampleTests extends SolrExampleTestsBase
// Now add something...
SolrInputDocument doc1 = new SolrInputDocument();
- doc1.addField( "id", "id1", 1.0f );
- doc1.addField( "name", "doc1", 1.0f );
+ doc1.addField( "id", "id1" );
+ doc1.addField( "name", "doc1" );
doc1.addField( "price", 10 );
SolrInputDocument doc2 = new SolrInputDocument();
- doc2.addField( "id", "id2", 1.0f );
- doc2.addField( "name", "h\uD866\uDF05llo", 1.0f );
+ doc2.addField( "id", "id2" );
+ doc2.addField( "name", "h\uD866\uDF05llo" );
doc2.addField( "price", 20 );
Collection<SolrInputDocument> docs = new ArrayList<>();
@@ -302,13 +302,13 @@ abstract public class SolrExampleTests extends SolrExampleTestsBase
// Add two docs
SolrInputDocument doc = new SolrInputDocument();
- doc.addField( "id", "id1", 1.0f );
- doc.addField( "name", "doc1", 1.0f );
+ doc.addField( "id", "id1" );
+ doc.addField( "name", "doc1" );
doc.addField( "price", 10 );
client.add(doc);
doc = new SolrInputDocument();
- doc.addField( "id", "id2", 1.0f );
+ doc.addField( "id", "id2" );
client.add(doc);
client.commit();
@@ -443,9 +443,9 @@ abstract public class SolrExampleTests extends SolrExampleTestsBase
}
SolrInputDocument doc = new SolrInputDocument();
- doc.addField("id", "DOCID", 1.0f);
- doc.addField("id", "DOCID2", 1.0f);
- doc.addField("name", "hello", 1.0f);
+ doc.addField("id", "DOCID");
+ doc.addField("id", "DOCID2");
+ doc.addField("name", "hello");
if (client instanceof HttpSolrClient) {
try {
@@ -484,15 +484,15 @@ abstract public class SolrExampleTests extends SolrExampleTestsBase
// Now add something...
SolrInputDocument doc = new SolrInputDocument();
- doc.addField( "id", "111", 1.0f );
- doc.addField( "name", "doc1", 1.0f );
+ doc.addField( "id", "111" );
+ doc.addField( "name", "doc1" );
doc.addField( "price", 11 );
client.add(doc);
client.commit(); // make sure this gets in first
doc = new SolrInputDocument();
- doc.addField( "id", "222", 1.0f );
- doc.addField( "name", "doc2", 1.0f );
+ doc.addField( "id", "222" );
+ doc.addField( "name", "doc2" );
doc.addField( "price", 22 );
client.add(doc);
client.commit();
@@ -539,8 +539,8 @@ abstract public class SolrExampleTests extends SolrExampleTestsBase
// Now add something...
SolrInputDocument doc = new SolrInputDocument();
- doc.addField( "id", "111", 1.0f );
- doc.addField( "name", "doc1", 1.0f );
+ doc.addField( "id", "111" );
+ doc.addField( "name", "doc1" );
doc.addField( "json_s", rawJson );
doc.addField( "xml_s", rawXml );
client.add(doc);
@@ -689,7 +689,7 @@ abstract public class SolrExampleTests extends SolrExampleTestsBase
SolrInputDocument[] doc = new SolrInputDocument[5];
for( int i=0; i<doc.length; i++ ) {
doc[i] = new SolrInputDocument();
- doc[i].setField( "id", "ID"+i, 1.0f );
+ doc[i].setField( "id", "ID"+i );
client.add(doc[i]);
}
client.commit();
@@ -844,7 +844,7 @@ abstract public class SolrExampleTests extends SolrExampleTestsBase
ArrayList<SolrInputDocument> docs = new ArrayList<>(10);
for( int i=1; i<=10; i++ ) {
SolrInputDocument doc = new SolrInputDocument();
- doc.setField( "id", i+"", 1.0f );
+ doc.setField( "id", i+"" );
if( (i%2)==0 ) {
doc.addField( "features", "two" );
}
@@ -1576,8 +1576,8 @@ abstract public class SolrExampleTests extends SolrExampleTestsBase
// Now add something...
SolrInputDocument doc = new SolrInputDocument();
- doc.addField( "id", "DOCID", 1.0f );
- doc.addField( "name", "hello", 1.0f );
+ doc.addField( "id", "DOCID" );
+ doc.addField( "name", "hello" );
client.add(doc);
client.commit(); // Since the transaction log is disabled in the example, we need to commit
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8ed2b764/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestsBase.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestsBase.java b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestsBase.java
index dc964cb..cda9961 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestsBase.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestsBase.java
@@ -50,8 +50,8 @@ abstract public class SolrExampleTestsBase extends SolrJettyTestBase {
// Now try a timed commit...
SolrInputDocument doc3 = new SolrInputDocument();
- doc3.addField("id", "id3", 1.0f);
- doc3.addField("name", "doc3", 1.0f);
+ doc3.addField("id", "id3");
+ doc3.addField("name", "doc3");
doc3.addField("price", 10);
UpdateRequest up = new UpdateRequest();
up.add(doc3);
@@ -87,8 +87,8 @@ abstract public class SolrExampleTestsBase extends SolrJettyTestBase {
// Now test the new convenience parameter on the add() for commitWithin
SolrInputDocument doc4 = new SolrInputDocument();
- doc4.addField("id", "id4", 1.0f);
- doc4.addField("name", "doc4", 1.0f);
+ doc4.addField("id", "id4");
+ doc4.addField("name", "doc4");
doc4.addField("price", 10);
client.add(doc4, 500);
@@ -125,8 +125,8 @@ abstract public class SolrExampleTestsBase extends SolrJettyTestBase {
// Now add one document...
SolrInputDocument doc3 = new SolrInputDocument();
- doc3.addField("id", "id3", 1.0f);
- doc3.addField("name", "doc3", 1.0f);
+ doc3.addField("id", "id3");
+ doc3.addField("name", "doc3");
doc3.addField("price", 10);
client.add(doc3);
client.commit();
@@ -169,7 +169,7 @@ abstract public class SolrExampleTestsBase extends SolrJettyTestBase {
SolrInputDocument[] doc = new SolrInputDocument[3];
for (int i = 0; i < 3; i++) {
doc[i] = new SolrInputDocument();
- doc[i].setField("id", i + " & 222", 1.0f);
+ doc[i].setField("id", i + " & 222");
}
String id = (String) doc[0].getField("id").getFirstValue();
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8ed2b764/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestUpdateRequestCodec.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestUpdateRequestCodec.java b/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestUpdateRequestCodec.java
index 53ad2eb..df7beea 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestUpdateRequestCodec.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestUpdateRequestCodec.java
@@ -53,20 +53,19 @@ public class TestUpdateRequestCodec extends LuceneTestCase {
updateRequest.setParam("a", "b");
SolrInputDocument doc = new SolrInputDocument();
doc.addField("id", 1);
- doc.addField("desc", "one", 2.0f);
+ doc.addField("desc", "one");
doc.addField("desc", "1");
updateRequest.add(doc);
doc = new SolrInputDocument();
doc.addField("id", 2);
- doc.setDocumentBoost(10.0f);
- doc.addField("desc", "two", 3.0f);
+ doc.addField("desc", "two");
doc.addField("desc", "2");
updateRequest.add(doc);
doc = new SolrInputDocument();
doc.addField("id", 3);
- doc.addField("desc", "three", 3.0f);
+ doc.addField("desc", "three");
doc.addField("desc", "3");
updateRequest.add(doc);
@@ -121,7 +120,7 @@ public class TestUpdateRequestCodec extends LuceneTestCase {
SolrInputDocument doc = new SolrInputDocument();
doc.addField("id", 1);
- doc.addField("desc", "one", 2.0f);
+ doc.addField("desc", "one");
// imagine someone adding a custom Bean that implements Iterable
// but is not a Collection
doc.addField("iter", new Iterable<String>() {
@@ -171,20 +170,19 @@ public class TestUpdateRequestCodec extends LuceneTestCase {
updateRequest.setParam("a", "b");
SolrInputDocument doc = new SolrInputDocument();
doc.addField("id", 1);
- doc.addField("desc", "one", 2.0f);
+ doc.addField("desc", "one");
doc.addField("desc", "1");
updateRequest.add(doc);
doc = new SolrInputDocument();
doc.addField("id", 2);
- doc.setDocumentBoost(10.0f);
- doc.addField("desc", "two", 3.0f);
+ doc.addField("desc", "two");
doc.addField("desc", "2");
updateRequest.add(doc);
doc = new SolrInputDocument();
doc.addField("id", 3);
- doc.addField("desc", "three", 3.0f);
+ doc.addField("desc", "three");
doc.addField("desc", "3");
updateRequest.add(doc);
@@ -234,14 +232,10 @@ public class TestUpdateRequestCodec extends LuceneTestCase {
private void compareDocs(String m,
SolrInputDocument expectedDoc,
SolrInputDocument actualDoc) {
- Assert.assertEquals(expectedDoc.getDocumentBoost(),
- actualDoc.getDocumentBoost());
for (String s : expectedDoc.getFieldNames()) {
SolrInputField expectedField = expectedDoc.getField(s);
SolrInputField actualField = actualDoc.getField(s);
- Assert.assertEquals(m + ": diff boosts for field: " + s,
- expectedField.getBoost(), actualField.getBoost());
Object expectedVal = expectedField.getValue();
Object actualVal = actualField.getValue();
if (expectedVal instanceof Set &&
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8ed2b764/solr/solrj/src/test/org/apache/solr/common/SolrDocumentTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/common/SolrDocumentTest.java b/solr/solrj/src/test/org/apache/solr/common/SolrDocumentTest.java
index 6b3318d..0234ce0 100644
--- a/solr/solrj/src/test/org/apache/solr/common/SolrDocumentTest.java
+++ b/solr/solrj/src/test/org/apache/solr/common/SolrDocumentTest.java
@@ -191,9 +191,9 @@ public class SolrDocumentTest extends LuceneTestCase
// Set up a simple document
SolrInputDocument doc = new SolrInputDocument();
for( int i=0; i<5; i++ ) {
- doc.addField( "f", fval0, 1.0f );
- doc.addField( "f", fval1, 1.0f );
- doc.addField( "f", fval2, 1.0f );
+ doc.addField( "f", fval0 );
+ doc.addField( "f", fval1 );
+ doc.addField( "f", fval2 );
}
assertEquals( (3*5), doc.getField("f").getValueCount() );
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8ed2b764/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
----------------------------------------------------------------------
diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
index e5bd384..c3c269c 100644
--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
@@ -2161,9 +2161,6 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
SolrInputDocument sdoc1 = (SolrInputDocument) expected;
SolrInputDocument sdoc2 = (SolrInputDocument) actual;
- if (Float.compare(sdoc1.getDocumentBoost(), sdoc2.getDocumentBoost()) != 0) {
- return false;
- }
if(sdoc1.getFieldNames().size() != sdoc2.getFieldNames().size()) {
return false;
@@ -2222,10 +2219,6 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
return false;
}
- if (Float.compare(sif1.getBoost(), sif2.getBoost()) != 0) {
- return false;
- }
-
return true;
}