Java Code Examples for org.alfresco.repo.search.adaptor.lucene.AnalysisMode

The following examples show how to use org.alfresco.repo.search.adaptor.lucene.AnalysisMode. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public Q addComponent(Set<String> selectors, Map<String, Argument> functionArgs, LuceneQueryBuilderContext<Q, S, E> luceneContext, FunctionEvaluationContext functionContext)
        throws E
{
    LuceneQueryParserAdaptor<Q, S, E> lqpa = luceneContext.getLuceneQueryParserAdaptor();
    Argument argument = functionArgs.get(ARG_FROM_INC);
    Boolean fromInc = (Boolean) argument.getValue(functionContext);
    argument = functionArgs.get(ARG_FROM);
    String from = (String) argument.getValue(functionContext);
    argument = functionArgs.get(ARG_TO);
    String to = (String) argument.getValue(functionContext);
    argument = functionArgs.get(ARG_TO_INC);
    Boolean toInc = (Boolean) argument.getValue(functionContext);
    
    PropertyArgument propArg = (PropertyArgument) functionArgs.get(ARG_PROPERTY);
    Q query;
    if (propArg != null)
    {
        String prop = propArg.getPropertyName();
        query = lqpa.getRangeQuery(functionContext.getLuceneFieldName(prop), from, to, fromInc, toInc, AnalysisMode.DEFAULT, LuceneFunction.FIELD);
    }
    else
    {
        query = lqpa.getRangeQuery(lqpa.getField(), from, to, fromInc, toInc, AnalysisMode.DEFAULT, LuceneFunction.FIELD);
    }
    return query;
}
 
Example 2
public Q addComponent(Set<String> selectors, Map<String, Argument> functionArgs, LuceneQueryBuilderContext<Q, S, E> luceneContext, FunctionEvaluationContext functionContext)
        throws E
{
    LuceneQueryParserAdaptor<Q, S, E> lqpa = luceneContext.getLuceneQueryParserAdaptor();
    Argument argument = functionArgs.get(ARG_TERM);
    String term = (String) argument.getValue(functionContext);
    argument = functionArgs.get(ARG_TOKENISATION_MODE);
    AnalysisMode mode = (AnalysisMode) argument.getValue(functionContext);

    PropertyArgument propArg = (PropertyArgument) functionArgs.get(ARG_PROPERTY);
    Q query;
    if (propArg != null)
    {
        String prop = propArg.getPropertyName();
        query = lqpa.getFieldQuery(functionContext.getLuceneFieldName(prop), term, mode, LuceneFunction.FIELD);
    }
    else
    {
        query = lqpa.getFieldQuery(lqpa.getField(), term, mode, LuceneFunction.FIELD);
        
    }
    return query;
}
 
Example 3
public Q addComponent(Set<String> selectors, Map<String, Argument> functionArgs, LuceneQueryBuilderContext<Q, S, E> luceneContext, FunctionEvaluationContext functionContext)
        throws E
{
    LuceneQueryParserAdaptor<Q, S, E> lqpa = luceneContext.getLuceneQueryParserAdaptor();
    Argument argument = functionArgs.get(ARG_TERM);
    String term = (String) argument.getValue(functionContext);

    argument = functionArgs.get(ARG_TOKENISATION_MODE);
    AnalysisMode mode = (AnalysisMode) argument.getValue(functionContext);
    
    PropertyArgument propArg = (PropertyArgument) functionArgs.get(ARG_PROPERTY);
    Q query;
    if (propArg != null)
    {
        String prop = propArg.getPropertyName();
        query = lqpa.getWildcardQuery(functionContext.getLuceneFieldName(prop), term, mode);
    }
    else
    {
        query = lqpa.getWildcardQuery(lqpa.getField(), term, mode);
        
    }
    return query;
}
 
Example 4
public Q addComponent(Set<String> selectors, Map<String, Argument> functionArgs, LuceneQueryBuilderContext<Q, S, E> luceneContext, FunctionEvaluationContext functionContext)
        throws E
{
    LuceneQueryParserAdaptor<Q, S, E> lqpa = luceneContext.getLuceneQueryParserAdaptor();
    Argument argument = functionArgs.get(ARG_TERM);
    String term = (String) argument.getValue(functionContext);
    // strip trailing wildcard *
    term = term.substring(0, term.length()-1);

    argument = functionArgs.get(ARG_TOKENISATION_MODE);
    AnalysisMode mode = (AnalysisMode) argument.getValue(functionContext);
    
    PropertyArgument propArg = (PropertyArgument) functionArgs.get(ARG_PROPERTY);
    Q query;
    if (propArg != null)
    {
        String prop = propArg.getPropertyName();
        query = lqpa.getPrefixQuery(functionContext.getLuceneFieldName(prop), term, mode);
    }
    else
    {
        query = lqpa.getPrefixQuery(lqpa.getField(), term, mode);
        
    }
    return query;
}
 
Example 5
@Override
public void prepare(NamespaceService namespaceService, DictionaryService dictionaryService, QNameDAO qnameDAO, NodeDAO nodeDAO, TenantService tenantService, Set<String> selectors,
        Map<String, Argument> functionArgs, FunctionEvaluationContext functionContext, boolean supportBooleanFloatAndDouble)
{
    Argument argument = functionArgs.get(ARG_TERM);
    String term = (String) argument.getValue(functionContext);
    // strip trailing wildcard *
    term = term.substring(0, term.length() - 1);
    PropertyArgument propertyArgument = (PropertyArgument) functionArgs.get(ARG_PROPERTY);

    argument = functionArgs.get(ARG_TOKENISATION_MODE);
    AnalysisMode mode = (AnalysisMode) argument.getValue(functionContext);
    if (mode != AnalysisMode.IDENTIFIER)
    {
        throw new QueryModelException("Analysis mode not supported for DB " + mode);
    }

    PropertySupport propertySupport = new PropertySupport();
    propertySupport.setValue(term + "%");

    QName propertyQName = QName.createQName(DBQuery.expandQName(functionContext.getAlfrescoPropertyName(propertyArgument.getPropertyName()), namespaceService));
    propertySupport.setPropertyQName(propertyQName);
    propertySupport.setPropertyDataType(DBQuery.getDataTypeDefinition(dictionaryService, propertyQName));
    propertySupport.setPair(qnameDAO.getQName(propertyQName));
    propertySupport.setJoinCommandType(DBQuery.getJoinCommandType(propertyQName));
    propertySupport.setFieldName(DBQuery.getFieldName(dictionaryService, propertyQName, supportBooleanFloatAndDouble));
    propertySupport.setCommandType(DBQueryBuilderPredicatePartCommandType.LIKE);
    builderSupport = propertySupport;

}
 
Example 6
public Q addComponent(Set<String> selectors, Map<String, Argument> functionArgs, LuceneQueryBuilderContext<Q, S, E> luceneContext, FunctionEvaluationContext functionContext)
        throws E
{
    LuceneQueryParserAdaptor<Q, S, E> lqpa = luceneContext.getLuceneQueryParserAdaptor();
    Argument argument = functionArgs.get(ARG_PHRASE);
    String term = (String) argument.getValue(functionContext);

    Integer slop = Integer.valueOf(lqpa.getPhraseSlop());
    argument = functionArgs.get(ARG_SLOP);
    if(argument != null)
    { 
       slop = (Integer) argument.getValue(functionContext);
    }
    
    argument = functionArgs.get(ARG_TOKENISATION_MODE);
    AnalysisMode mode = (AnalysisMode) argument.getValue(functionContext);
    
    PropertyArgument propArg = (PropertyArgument) functionArgs.get(ARG_PROPERTY);
    Q query;
    if (propArg != null)
    {
        String prop = propArg.getPropertyName();
        query = lqpa.getFieldQuery(functionContext.getLuceneFieldName(prop), term, mode, slop, LuceneFunction.FIELD);
    }
    else
    {
        query = lqpa.getFieldQuery(lqpa.getField(), term, mode, slop, LuceneFunction.FIELD);
    }
    return query;
}
 
Example 7
@Override
public <Q, S, E extends Throwable> Q buildLuceneExists(LuceneQueryParserAdaptor<Q, S, E> lqpa, Boolean not) throws E
{
    if (not)
    {
        return lqpa.getFieldQuery("ISNULL", getQNameForExists().toString(), AnalysisMode.DEFAULT, LuceneFunction.FIELD);
    }
    else
    {
        return lqpa.getFieldQuery("ISNOTNULL", getQNameForExists().toString(), AnalysisMode.DEFAULT, LuceneFunction.FIELD);
    }
}
 
Example 8
@Override
public <Q, S, E extends Throwable> Q buildLuceneGreaterThan(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
{
    String field = getLuceneFieldName();
    String stringValue = getValueAsString(value);
    return lqpa.getRangeQuery(field, stringValue, getRangeMax(), false, true, AnalysisMode.IDENTIFIER, luceneFunction);
}
 
Example 9
@Override
public <Q, S, E extends Throwable> Q buildLuceneGreaterThanOrEquals(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
{
    String field = getLuceneFieldName();
    String stringValue = getValueAsString(value);
    return lqpa.getRangeQuery(field, stringValue, getRangeMax(), true, true, AnalysisMode.IDENTIFIER, luceneFunction);
}
 
Example 10
@Override
public <Q, S, E extends Throwable> Q buildLuceneLessThan(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
{
    String field = getLuceneFieldName();
    String stringValue = getValueAsString(value);
    return lqpa.getRangeQuery(field, getRangeMin(), stringValue, true, false, AnalysisMode.IDENTIFIER, luceneFunction);
}
 
Example 11
@Override
public <Q, S, E extends Throwable> Q buildLuceneLessThanOrEquals(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
{
    String field = getLuceneFieldName();
    String stringValue = getValueAsString(value);
    return lqpa.getRangeQuery(field, getRangeMin(), stringValue, true, true, AnalysisMode.IDENTIFIER, luceneFunction);
}
 
Example 12
@Override
public <Q, S, E extends Throwable> Q buildLuceneLike(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, Boolean not) throws E
{
    String field = getLuceneFieldName();
    String stringValue = getValueAsString(value);

    Q q =  lqpa.getLikeQuery(field, stringValue, AnalysisMode.IDENTIFIER);
    if (not)
    {
        q = lqpa.getNegatedQuery(q);
    }
    return q;
}
 
Example 13
@Override
public <Q, S, E extends Throwable> Q buildLuceneEquality(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode,
        LuceneFunction luceneFunction) throws E
{
    String field = getLuceneFieldName();
    String stringValue = getValueAsString(lqpa, value);
    return lqpa.getFieldQuery(field, stringValue, AnalysisMode.IDENTIFIER, luceneFunction);
}
 
Example 14
@Override
public <Q, S, E extends Throwable> Q buildLuceneExists(LuceneQueryParserAdaptor<Q, S, E> lqpa, Boolean not) throws E
{
    if (not)
    {
        return lqpa.getFieldQuery("ISROOT", "T", AnalysisMode.IDENTIFIER, LuceneFunction.FIELD);
    } else
    {
        return lqpa.getNegatedQuery(lqpa.getFieldQuery("ISROOT", "T", AnalysisMode.IDENTIFIER, LuceneFunction.FIELD));
    }
}
 
Example 15
@Override
public <Q, S, E extends Throwable> Q buildLuceneLike(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, Boolean not) throws E
{
    String field = getLuceneFieldName();
    String stringValue = getValueAsString(lqpa, value);

    Q q = lqpa.getLikeQuery(field, stringValue, AnalysisMode.IDENTIFIER);
    if (not)
    {
        return lqpa.getNegatedQuery(q);
    }
    return q;
}
 
Example 16
@Override
public <Q, S, E extends Throwable> Q buildLuceneEquality(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
{
    String field = getLuceneFieldName();
    String stringValue = getValueAsString(lqpa, value);
    return lqpa.getIdentifierQuery(field, stringValue, AnalysisMode.IDENTIFIER, luceneFunction);
}
 
Example 17
@Override
public <Q, S, E extends Throwable> Q buildLuceneLike(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, Boolean not) throws E
{
    String field = getLuceneFieldName();
    String stringValue = getValueAsString(lqpa, value);

    Q q = lqpa.getIdentifieLikeQuery(field, stringValue, AnalysisMode.IDENTIFIER);
    if(not)
    {
        q = lqpa.getNegatedQuery(q);
    }
    return q; 
}
 
Example 18
@Override
public <Q, S, E extends Throwable> Q buildLuceneEquality(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode,
        LuceneFunction luceneFunction) throws E
{
    String field = getLuceneFieldName();
    String stringValue = getValueAsString(value);
    TypeDefinitionWrapper type = cmisDictionaryService.findType(stringValue);
    return lqpa
            .getFieldQuery(field, type.getAlfrescoClass().toString(), AnalysisMode.IDENTIFIER, luceneFunction);
}
 
Example 19
@Override
public <Q, S, E extends Throwable> Q buildLuceneLike(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, Boolean not) throws E
{
    String field = getLuceneFieldName();
    String stringValue = getValueAsString(value);
    TypeDefinitionWrapper type = cmisDictionaryService.findType(stringValue);
    String typeQName = type.getAlfrescoClass().toString();

    Q q = lqpa.getLikeQuery(field, typeQName, AnalysisMode.IDENTIFIER);
    if (not)
    {
        q = lqpa.getNegatedQuery(q);
    } 
    return q;
}
 
Example 20
static private Constraint buildPhrase(CommonTree testNode, QueryModelFactory factory,
        FunctionEvaluationContext functionEvaluationContext, Selector selector, Map<String, Column> columnMap)
{
    String functionName = FTSPhrase.NAME;
    Function function = factory.getFunction(functionName);
    Map<String, Argument> functionArguments = new LinkedHashMap<String, Argument>();
    LiteralArgument larg = factory.createLiteralArgument(FTSPhrase.ARG_PHRASE, DataTypeDefinition.TEXT, getText(testNode.getChild(0)));
    functionArguments.put(larg.getName(), larg);
    larg = factory.createLiteralArgument(FTSPhrase.ARG_TOKENISATION_MODE, DataTypeDefinition.ANY, AnalysisMode.DEFAULT);
    functionArguments.put(larg.getName(), larg);
    return factory.createFunctionalConstraint(function, functionArguments);
}
 
Example 21
static private Constraint buildTerm(CommonTree testNode, QueryModelFactory factory, FunctionEvaluationContext functionEvaluationContext,
        Selector selector, Map<String, Column> columnMap)
{
    String functionName = FTSTerm.NAME;
    Function function = factory.getFunction(functionName);
    Map<String, Argument> functionArguments = new LinkedHashMap<String, Argument>();
    LiteralArgument larg = factory.createLiteralArgument(FTSTerm.ARG_TERM, DataTypeDefinition.TEXT, getText(testNode.getChild(0)));
    functionArguments.put(larg.getName(), larg);
    larg = factory.createLiteralArgument(FTSTerm.ARG_TOKENISATION_MODE, DataTypeDefinition.ANY, AnalysisMode.DEFAULT);
    functionArguments.put(larg.getName(), larg);
    return factory.createFunctionalConstraint(function, functionArguments);
}
 
Example 22
@Override
public Query getIdentifierQuery(String field, String stringValue, AnalysisMode analysisMode, LuceneFunction luceneFunction) throws ParseException
{
    String[] split = stringValue.split(";");
    if(split.length == 1)
    {
        return lqp.getFieldQuery(field, stringValue, AnalysisMode.IDENTIFIER, luceneFunction);
    }
    else
    {
        if(split[1].equalsIgnoreCase("PWC"))
        {
            return getMatchNoneQuery();
        }
        
        BooleanQuery.Builder query = new BooleanQuery.Builder();
        BooleanQuery.Builder part1 = new BooleanQuery.Builder();
        part1.add(lqp.getFieldQuery(field, split[0], AnalysisMode.IDENTIFIER, luceneFunction), Occur.MUST);
        part1.add(lqp.getFieldQuery("@"+ContentModel.PROP_VERSION_LABEL.toString(), split[1], AnalysisMode.IDENTIFIER, luceneFunction), Occur.MUST);
        query.add(part1.build(), Occur.SHOULD);
        
        if(split[1].equals("1.0"))
        {
            BooleanQuery.Builder part2 = new BooleanQuery.Builder();
            part2.add(lqp.getFieldQuery(field, split[0], AnalysisMode.IDENTIFIER, luceneFunction), Occur.MUST);
            part2.add(lqp.getFieldQuery(QueryConstants.FIELD_ASPECT, ContentModel.ASPECT_VERSIONABLE.toString(), AnalysisMode.IDENTIFIER, luceneFunction), Occur.MUST_NOT);
            query.add(part2.build(), Occur.SHOULD);
        }
        return query.build();
    }
}
 
Example 23
@Override
public <Q, S, E extends Throwable> Q buildLuceneEquality(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
{
    return lqpa.getFieldQuery(getLuceneFieldName(), getValueAsString(value), AnalysisMode.IDENTIFIER, luceneFunction);
}
 
Example 24
@Override
public <Q, S, E extends Throwable> Q buildLuceneEquality(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
{
    return lqpa.getFieldQuery("TYPE", getType(getValueAsString(value)), AnalysisMode.IDENTIFIER, luceneFunction);     
}
 
Example 25
@Override
public Query getFieldQuery(String field, String queryText, AnalysisMode analysisMode, LuceneFunction luceneFunction) throws ParseException
{
    return lqp.getFieldQuery(field, queryText, analysisMode, luceneFunction);
}
 
Example 26
@Override
public Query getRangeQuery(String field, String lower, String upper, boolean includeLower, boolean includeUpper, AnalysisMode analysisMode, LuceneFunction luceneFunction)
        throws ParseException
{
    return lqp.getRangeQuery(field, lower, upper, includeLower, includeUpper, analysisMode, luceneFunction);
}
 
Example 27
@Override
public Query getLikeQuery(String field, String sqlLikeClause, AnalysisMode analysisMode) throws ParseException
{
    return lqp.getLikeQuery(field, sqlLikeClause, analysisMode);
}
 
Example 28
@Override
public Query getIdentifieLikeQuery(String field, String sqlLikeClause, AnalysisMode analysisMode) throws ParseException
{
    return getLikeQuery(field, sqlLikeClause, analysisMode);
}
 
Example 29
@Override
public Query getFieldQuery(String luceneFieldName, String term, AnalysisMode analysisMode, Integer slop, LuceneFunction luceneFunction) throws ParseException
{
    return lqp.getFieldQuery(luceneFieldName, term, analysisMode, slop, luceneFunction);
}
 
Example 30
@Override
public Query getPrefixQuery(String luceneFieldName, String term, AnalysisMode analysisMode) throws ParseException
{
    return lqp.getPrefixQuery(luceneFieldName, term, analysisMode);
}