Commit 458b4f57 authored by Frank van Lankvelt's avatar Frank van Lankvelt

CMS7-6934: import search service addon

parents
* text=auto !eol
/LICENSE -text
/NOTICE -text
jcr/src/main/resources/hipposearch.cnd -text
jcr/src/test/resources/testproject-types.cnd -text
Copyright 2013 Hippo B.V. (http://www.onehippo.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.
Hippo Search Service
Copyright 2013 Hippo B.V. (http://www.onehippo.com)
This product includes software developed by:
Hippo B.V., Amsterdam, The Netherlands (http://www.onehippo.com/);
The Apache Software Foundation (http://www.apache.org/).
NOTICE: Only our own original work is licensed under the terms of the
Apache License Version 2.0. The licenses of some libraries might impose
different redistribution or general licensing terms than those stated in the
Apache License. Users and redistributors are hereby requested to verify these
conditions and agree upon them.
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2013 Hippo B.V. (http://www.onehippo.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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.onehippo.cms7</groupId>
<artifactId>hippo-search-service</artifactId>
<version>1.01.00-SNAPSHOT</version>
</parent>
<name>Hippo Search Service API</name>
<description>Hippo Search Service API</description>
<artifactId>hippo-search-service-api</artifactId>
<packaging>jar</packaging>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<aggregate>true</aggregate>
</configuration>
</plugin>
</plugins>
</reporting>
<build>
<defaultGoal>package</defaultGoal>
</build>
</project>
/*
* Copyright 2012-2013 Hippo B.V. (http://www.onehippo.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 org.onehippo.cms7.services.search.content;
import java.io.Serializable;
/**
* ID representation which can provide a stringified ID.
* Also, search service implementation may require some specific
* ID representation objects implementing this interface for
* any extensible features.
*/
public interface ContentId extends Serializable {
ContentId UNKNOWN = new ContentId() {
@Override
public String toIdentifier() {
return "<unknown-content-id>";
}
};
/**
* Returns a stringified ID string
* @return
*/
public String toIdentifier();
}
/*
* Copyright 2012-2013 Hippo B.V. (http://www.onehippo.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 org.onehippo.cms7.services.search.document;
import java.util.Collection;
import org.onehippo.cms7.services.search.content.ContentId;
/**
* Representation of a document from the search engine.
*/
public interface FieldsDocument {
/**
* Return type name
* @return
*/
public String getPrimaryTypeName();
/**
* Returns content ID
* @return
*/
public ContentId getContentId();
/**
* Checks whether field with the name exists
* @param name
* @return
*/
public boolean hasField(String name);
/**
* @return a list of fields defined in this document
*/
public Collection<String> getFieldNames();
/**
* Get the value or collection of values for a given field.
*/
public Object getFieldValue(String name);
/**
* Get a collection of values for a given field name
*/
public Collection<Object> getFieldValues(String name);
/**
* returns the first value for a field
*/
public Object getFirstFieldValue(String name);
}
/*
* Copyright 2012-2013 Hippo B.V. (http://www.onehippo.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 org.onehippo.cms7.services.search.document;
import java.util.Collection;
import java.util.Collections;
import org.onehippo.cms7.services.search.content.ContentId;
/**
* Representation of a document from the search engine.
*/
public interface SearchDocument extends FieldsDocument {
SearchDocument EMPTY = new SearchDocument() {
@Override
public String getPrimaryTypeName() {
return "nt:base";
}
@Override
public ContentId getContentId() {
return ContentId.UNKNOWN;
}
@Override
public boolean hasField(final String name) {
return false;
}
@Override
public Collection<String> getFieldNames() {
return Collections.emptyList();
}
@Override
public Object getFieldValue(final String name) {
return null;
}
@Override
public Collection<Object> getFieldValues(final String name) {
return Collections.emptyList();
}
@Override
public Object getFirstFieldValue(final String name) {
return null;
}
};
}
/*
* Copyright 2012-2013 Hippo B.V. (http://www.onehippo.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 org.onehippo.cms7.services.search.query;
import org.onehippo.cms7.services.search.query.constraint.Constraint;
public interface AndClause extends Query {
AndClause and(Constraint constraint);
}
/*
* Copyright 2012-2013 Hippo B.V. (http://www.onehippo.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 org.onehippo.cms7.services.search.query;
public interface InitialQuery extends ScopedQuery {
ScopeClause from(String path);
}
/*
* Copyright 2012-2013 Hippo B.V. (http://www.onehippo.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 org.onehippo.cms7.services.search.query;
import org.onehippo.cms7.services.search.query.constraint.Constraint;
public interface OrClause extends Query {
OrClause or(Constraint constraint);
}
/*
* Copyright 2012-2013 Hippo B.V. (http://www.onehippo.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 org.onehippo.cms7.services.search.query;
public interface OrderClause extends Query {
Query ascending();
Query descending();
}
/*
* Copyright 2012-2013 Hippo B.V. (http://www.onehippo.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 org.onehippo.cms7.services.search.query;
public interface Query {
public Query EMPTY = new EmptyQuery();
Query offsetBy(int offset);
Query limitTo(int limit);
OrderClause orderBy(String property);
}
final class EmptyQuery implements Query, OrderClause {
@Override
public Query offsetBy(final int offset) {
return this;
}
@Override
public Query limitTo(final int limit) {
return this;
}
@Override
public OrderClause orderBy(final String property) {
return this;
}
@Override
public Query ascending() {
return this;
}
@Override
public Query descending() {
return this;
}
}
/*
* Copyright 2012-2013 Hippo B.V. (http://www.onehippo.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 org.onehippo.cms7.services.search.query;
import org.onehippo.cms7.services.search.query.constraint.AndConstraint;
import org.onehippo.cms7.services.search.query.constraint.CompoundConstraint;
import org.onehippo.cms7.services.search.query.constraint.Constraint;
import org.onehippo.cms7.services.search.query.constraint.NotConstraint;
import org.onehippo.cms7.services.search.query.constraint.OrConstraint;
import org.onehippo.cms7.services.search.query.field.DateField;
import org.onehippo.cms7.services.search.query.field.IntegerField;
import org.onehippo.cms7.services.search.query.field.TextField;
import org.onehippo.cms7.services.search.result.QueryResult;
import org.onehippo.cms7.services.search.service.SearchService;
public abstract class QueryBuilder {
protected QueryBuilder() {
}
protected final TextField text(String property) {
return new TextField(property);
}
protected final TextField text() {
return new TextField();
}
protected final DateField date(String property) {
return new DateField(property);
}
protected final IntegerField integer(String property) {
return new IntegerField(property);
}
protected final OrConstraint either(Constraint constraint) {
return new CompoundConstraint(constraint, CompoundConstraint.Type.OR);
}
protected final AndConstraint both(Constraint constraint) {
return new CompoundConstraint(constraint, CompoundConstraint.Type.AND);
}
protected final Constraint not(Constraint constraint) {
return new NotConstraint(constraint);
}
}
/*
* Copyright 2012-2013 Hippo B.V. (http://www.onehippo.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 org.onehippo.cms7.services.search.query;
import org.onehippo.cms7.services.search.query.constraint.AndConstraint;
import org.onehippo.cms7.services.search.query.constraint.Constraint;
import org.onehippo.cms7.services.search.query.constraint.OrConstraint;
import org.onehippo.cms7.services.search.query.field.DateField;
import org.onehippo.cms7.services.search.query.field.IntegerField;
import org.onehippo.cms7.services.search.query.field.TextField;
public class QueryUtils {
private static final QueryBuilder BUILDER = new QueryBuilder() {};
private QueryUtils() {
}
public static TextField text(String property) {
return BUILDER.text(property);
}
public static TextField text() {
return BUILDER.text();
}
public static DateField date(String property) {
return BUILDER.date(property);
}
public static IntegerField integer(String property) {
return BUILDER.integer(property);
}
public static OrConstraint either(Constraint constraint) {
return BUILDER.either(constraint);
}
public static AndConstraint both(Constraint constraint) {
return BUILDER.both(constraint);
}
public static Constraint not(Constraint constraint) {
return BUILDER.not(constraint);
}
}
/*
* Copyright 2012-2013 Hippo B.V. (http://www.onehippo.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 org.onehippo.cms7.services.search.query;
public interface ScopeClause extends ScopedQuery {
ScopeClause or(String path);
ScopeClause except(String path);
}
/*
* Copyright 2012-2013 Hippo B.V. (http://www.onehippo.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 org.onehippo.cms7.services.search.query;
public interface ScopedQuery extends TypedQuery {
TypedQuery ofType(String type);
}
/*
* Copyright 2012-2013 Hippo B.V. (http://www.onehippo.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 org.onehippo.cms7.services.search.query;
import org.onehippo.cms7.services.search.query.steps.WhereStep;
public interface SelectClause extends Query, WhereStep {
SelectClause and(String property);
}
/*
* Copyright 2012-2013 Hippo B.V. (http://www.onehippo.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 org.onehippo.cms7.services.search.query;
import org.onehippo.cms7.services.search.query.steps.WhereStep;
public interface TypedQuery extends Query, WhereStep {
SelectClause select(String property);
}
/*
* Copyright 2012-2013 Hippo B.V. (http://www.onehippo.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 org.onehippo.cms7.services.search.query;
public interface WhereClause extends Query, AndClause, OrClause {
}
/*
* Copyright 2012-2013 Hippo B.V. (http://www.onehippo.com)
*