com.stratio.cassandra.lucene.search.condition.SingleFieldCondition Maven / Gradle / Ivy
The newest version!
/*
* Copyright (C) 2014 Stratio (http://stratio.com)
*
* Licensed 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.
*/
package com.stratio.cassandra.lucene.search.condition;
import com.google.common.base.MoreObjects;
import com.stratio.cassandra.lucene.IndexException;
import org.apache.commons.lang3.StringUtils;
import java.util.Collections;
import java.util.Set;
/**
* The abstract base class for queries directed to a specific field which name should be specified.
*
* Known subclasses are: - {@link FuzzyCondition}
- {@link MatchCondition}
- {@link PhraseCondition}
-
* {@link PrefixCondition}
- {@link RangeCondition}
- {@link WildcardCondition}
- {@link BitemporalCondition}
*
- {@link DateRangeCondition}
- {@link GeoDistanceCondition}
- {@link GeoBBoxCondition}
- {@link
* GeoShapeCondition}
*
* @author Andres de la Pena {@literal }
*/
public abstract class SingleFieldCondition extends Condition {
/** The name of the field to be matched. */
public final String field;
/**
* Abstract {@link SingleFieldCondition} builder receiving the boost to be used.
*
* @param boost the boost for this query clause. Documents matching this clause will (in addition to the normal
* weightings) have their score multiplied by {@code boost}.
* @param field the name of the field to be matched
*/
public SingleFieldCondition(Float boost, String field) {
super(boost);
if (StringUtils.isBlank(field)) {
throw new IndexException("Field name required");
}
this.field = field;
}
/** {@inheritDoc} */
public Set postProcessingFields() {
return Collections.singleton(field);
}
/** {@inheritDoc} */
@Override
protected MoreObjects.ToStringHelper toStringHelper(Object o) {
return super.toStringHelper(o).add("field", field);
}
}