mirror of https://github.com/apache/lucene.git
SOLR-3702: Reverting commit because it breaks QueryEqualityTest
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1550676 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
78d8d0c535
commit
f590fe62a6
|
@ -1,75 +0,0 @@
|
|||
package org.apache.lucene.queries.function.valuesource;
|
||||
|
||||
/*
|
||||
* 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.lucene.index.AtomicReaderContext;
|
||||
import org.apache.lucene.queries.function.FunctionValues;
|
||||
import org.apache.lucene.queries.function.ValueSource;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A {@link ValueSource} implementation which concatenates existing string
|
||||
* values from the provided ValueSources into one string.
|
||||
*/
|
||||
public class ConcatenateFunction extends MultiFunction {
|
||||
|
||||
public ConcatenateFunction(List<ValueSource> sources) {
|
||||
super(sources);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String name() {
|
||||
return "concat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
|
||||
return new Values(valsArr(sources, context, readerContext)) {
|
||||
|
||||
@Override
|
||||
public String strVal(int doc) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (FunctionValues functionValues : valsArr) {
|
||||
if (functionValues.exists(doc)) {
|
||||
stringBuilder.append(functionValues.strVal(doc));
|
||||
}
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object objectVal(int doc) {
|
||||
return strVal(doc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exists(int doc) {
|
||||
for (FunctionValues vals : valsArr) {
|
||||
if (vals.exists(doc)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -127,9 +127,6 @@ New Features
|
|||
* SOLR-1871: The 'map' function query accepts a ValueSource as target and
|
||||
default value. (Chris Harris, shalin)
|
||||
|
||||
* SOLR-3702: A 'concat' function query to support concatenation of Strings.
|
||||
(Ted Strauss, Andrey Kudryavtsev via shalin)
|
||||
|
||||
Bug Fixes
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -779,13 +779,6 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin {
|
|||
}
|
||||
});
|
||||
|
||||
addParser("concat", new ValueSourceParser() {
|
||||
@Override
|
||||
public ValueSource parse(FunctionQParser fp) throws SyntaxError {
|
||||
return new ConcatenateFunction(fp.parseValueSourceList());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private static TInfo parseTerm(FunctionQParser fp) throws SyntaxError {
|
||||
|
|
|
@ -754,24 +754,4 @@ public class TestFunctionQuery extends SolrTestCaseJ4 {
|
|||
}
|
||||
}
|
||||
|
||||
public void testConcatFunction() {
|
||||
clearIndex();
|
||||
|
||||
assertU(adoc("id", "1", "field1_t", "buzz", "field2_t", "word"));
|
||||
assertU(adoc("id", "2", "field1_t", "1", "field2_t", "2","field4_t", "4"));
|
||||
assertU(commit());
|
||||
|
||||
assertQ(req("q","id:1",
|
||||
"fl","field:concat(field1_t,field2_t)"),
|
||||
" //str[@name='field']='buzzword'");
|
||||
|
||||
assertQ(req("q","id:2",
|
||||
"fl","field:concat(field1_t,field2_t, field3_t, field4_t)"),
|
||||
" //str[@name='field']='124'");
|
||||
|
||||
assertQ(req("q","id:1",
|
||||
"fl","field:def(concat(field3_t, field4_t), 'defValue')"),
|
||||
" //str[@name='field']='defValue'");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue