public class QueryFactory
extends java.lang.Object
LuceneSearch
instance which has been created for a
CDM base type.getTextFieldNames()
or getTextFieldNamesAsArray()
.
This is useful for highlighting the matches with LuceneSearch.setHighlightFields(String[])
The index specific methods from LuceneSearch
which are
used by QueryFactory directly or indirectly are:
Modifier and Type | Field and Description |
---|---|
static Logger |
logger |
protected ILuceneIndexToolProvider |
toolProvider |
Constructor and Description |
---|
QueryFactory(ILuceneIndexToolProvider toolProvider,
java.lang.Class<? extends CdmBase> cdmBaseType) |
Modifier and Type | Method and Description |
---|---|
static org.apache.lucene.search.BooleanQuery.Builder |
addTypeRestriction(org.apache.lucene.search.Query query,
java.lang.Class<? extends CdmBase> cdmTypeRestriction)
Creates a class restriction query and wraps the class restriction
query and the given
query into a BooleanQuery where both must match. |
static org.apache.lucene.search.Query |
buildSpatialQueryByRange(org.hibernate.search.spatial.impl.Rectangle boundingBox,
java.lang.String fieldName)
Returns a Lucene Query which rely on double numeric range query
on Latitude / Longitude
(+/- copied from
SpatialQueryBuilderFromPoint#buildSpatialQueryByRange(Point, double, String) ) |
java.util.Set<java.lang.String> |
getTextFieldNames() |
java.lang.String[] |
getTextFieldNamesAsArray() |
org.apache.lucene.search.Query |
newBooleanQuery(java.lang.String fieldName,
boolean value) |
org.apache.lucene.search.Query |
newDefinedTermQuery(java.lang.String name,
java.lang.String queryString,
java.util.List<Language> languages)
DefinedTerms are stored in the Lucene index by the
DefinedTermBaseClassBridge in a consistent way. |
org.apache.lucene.search.Query |
newEntityIdQuery(java.lang.String idFieldName,
CdmBase entitiy) |
org.apache.lucene.search.Query |
newEntityIdsQuery(java.lang.String idFieldName,
java.util.Collection<? extends CdmBase> entities) |
org.apache.lucene.search.Query |
newEntityUuidQuery(java.lang.String uuidFieldName,
IdentifiableEntity entity) |
org.apache.lucene.search.Query |
newEntityUuidsQuery(java.lang.String uuidFieldName,
java.util.List<? extends IdentifiableEntity> entities)
Creates a query for searching for documents in which the field specified by
uuidFieldName
matches at least one of the uuid of the entities , the sql equivalent of this is
WHERE uuidFieldName IN (uuid_1, uuid_2, ...) . |
org.apache.lucene.search.Query |
newIsNotNullQuery(java.lang.String idFieldName) |
org.apache.lucene.search.Query |
newJoinQuery(java.lang.Class<? extends CdmBase> fromType,
java.lang.String fromField,
boolean fromFieldIsMultivalued,
org.apache.lucene.search.Query fromQuery,
java.lang.String toField,
java.lang.Class<? extends CdmBase> toType,
org.apache.lucene.search.join.ScoreMode scoreMode)
Warning! JoinQuery do currently not work with numeric fields, see https://issues.apache.org/jira/browse/LUCENE-4824
|
org.apache.lucene.search.Query |
newMultilanguageTextQuery(java.lang.String name,
java.lang.String queryString,
java.util.List<Language> languages)
MultilanguageString maps are stored in the Lucene index by the
MultilanguageTextFieldBridge in a consistent way. |
org.apache.lucene.search.Query |
newTermQuery(java.lang.String fieldName,
java.lang.String queryString)
Only to be used for text fields, see
newTermQuery(String, String, boolean) |
org.apache.lucene.search.Query |
newTermQuery(java.lang.String fieldName,
java.lang.String queryString,
boolean isTextField)
Creates a new Term query.
|
org.apache.lucene.search.Query |
newUuidQuery(java.lang.String uuidFieldName,
java.util.List<java.util.UUID> uuids)
Creates a query for searching for documents in which the field specified by
uuidFieldName matches at least one of the
supplied uuids
the sql equivalent of this is WHERE uuidFieldName IN (uuid_1, uuid_2, ...) . |
public static final Logger logger
protected ILuceneIndexToolProvider toolProvider
public QueryFactory(ILuceneIndexToolProvider toolProvider, java.lang.Class<? extends CdmBase> cdmBaseType)
public java.util.Set<java.lang.String> getTextFieldNames()
public java.lang.String[] getTextFieldNamesAsArray()
public org.apache.lucene.search.Query newTermQuery(java.lang.String fieldName, java.lang.String queryString, boolean isTextField)
isTextField
is set true or not the
supplied queryString
will be parsed by using the according analyzer or not.
Setting isTextField
to false
is useful for searching for uuids etc.
The appropriate query type is determined by the query strnig:
fieldName
- queryString
- isTextField
- whether this field is a field containing free text in contrast to e.g. ID fields.
If isTextField
is set true
the queryString
will be parsed by
using the according analyzer.TermQuery
or null
in case of an ParseException
TODO consider throwing the ParseException !!!!public org.apache.lucene.search.Query newTermQuery(java.lang.String fieldName, java.lang.String queryString)
newTermQuery(String, String, boolean)
fieldName
- queryString
- TermQuery
or a WildcardQuery
public org.apache.lucene.search.Query newBooleanQuery(java.lang.String fieldName, boolean value)
public org.apache.lucene.search.Query newDefinedTermQuery(java.lang.String name, java.lang.String queryString, java.util.List<Language> languages)
DefinedTermBaseClassBridge
in a consistent way. One field per
language and also in one additional field for all languages. This method
is a convenient means to retrieve a Lucene query string for such the
fields.name
- name of the term field as in the Lucene index. The field must
have been written to Lucene document by
DefinedTermBaseClassBridge
languages
- the languages to search for exclusively. Can be
null
to search in all languagespublic org.apache.lucene.search.Query newMultilanguageTextQuery(java.lang.String name, java.lang.String queryString, java.util.List<Language> languages)
MultilanguageTextFieldBridge
in a consistent way. One field per
language and also in one additional field for all languages. This method
is a convenient means to retrieve a Lucene query string for such the
fields.name
- name of the term field as in the Lucene index. The field must
have been written to Lucene document by
DefinedTermBaseClassBridge
languages
- the languages to search for exclusively. Can be
null
to search in all languagespublic org.apache.lucene.search.Query newEntityIdQuery(java.lang.String idFieldName, CdmBase entitiy)
idFieldName
- entitiy
- public org.apache.lucene.search.Query newEntityIdsQuery(java.lang.String idFieldName, java.util.Collection<? extends CdmBase> entities)
idFieldName
- entitiy
- public org.apache.lucene.search.Query newIsNotNullQuery(java.lang.String idFieldName)
idFieldName
- public org.apache.lucene.search.Query newEntityUuidQuery(java.lang.String uuidFieldName, IdentifiableEntity entity)
uuidFieldName
- entity
- public org.apache.lucene.search.Query newEntityUuidsQuery(java.lang.String uuidFieldName, java.util.List<? extends IdentifiableEntity> entities)
uuidFieldName
matches at least one of the uuid of the entities
, the sql equivalent of this is
WHERE uuidFieldName IN (uuid_1, uuid_2, ...)
.uuidFieldName
- entities
- public org.apache.lucene.search.Query newUuidQuery(java.lang.String uuidFieldName, java.util.List<java.util.UUID> uuids)
uuidFieldName
matches at least one of the
supplied uuids
the sql equivalent of this is WHERE uuidFieldName IN (uuid_1, uuid_2, ...)
.uuidFieldName
- entities
- public static org.apache.lucene.search.Query buildSpatialQueryByRange(org.hibernate.search.spatial.impl.Rectangle boundingBox, java.lang.String fieldName)
SpatialQueryBuilderFromPoint#buildSpatialQueryByRange(Point, double, String)
)center
- center of the search discusradius
- distance max to center in kmfieldName
- name of the Lucene Field implementing CoordinatesQuery
,
Coordinates
public org.apache.lucene.search.Query newJoinQuery(java.lang.Class<? extends CdmBase> fromType, java.lang.String fromField, boolean fromFieldIsMultivalued, org.apache.lucene.search.Query fromQuery, java.lang.String toField, java.lang.Class<? extends CdmBase> toType, org.apache.lucene.search.join.ScoreMode scoreMode) throws java.io.IOException
fromType
- fromField
- fromFieldIsMultivalued
- TODOfromQuery
- toField
- toType
- Optional parameter. Only used for debugging only, can be left null otherwise.scoreMode
- TODOjava.io.IOException
public static org.apache.lucene.search.BooleanQuery.Builder addTypeRestriction(org.apache.lucene.search.Query query, java.lang.Class<? extends CdmBase> cdmTypeRestriction)
query
into a BooleanQuery where both must match.
cdmTypeRestriction
- query
- Copyright © 2007-2020 EDIT. All Rights Reserved.