Compatible with social model 2.0.0
This commit is contained in:
parent
9defeb589d
commit
ebe62bda4e
48
pom.xml
48
pom.xml
|
@ -5,13 +5,13 @@
|
|||
<parent>
|
||||
<artifactId>maven-parent</artifactId>
|
||||
<groupId>org.gcube.tools</groupId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.1.0</version>
|
||||
<relativePath />
|
||||
</parent>
|
||||
|
||||
<groupId>org.gcube.socialnetworking</groupId>
|
||||
<artifactId>social-data-search-client</artifactId>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<version>2.0.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Social Data Search Client</name>
|
||||
|
@ -31,8 +31,8 @@
|
|||
<guavaVersion>18.0</guavaVersion>
|
||||
<serviceClass>social-networking</serviceClass>
|
||||
<distroDirectory>distro</distroDirectory>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
</properties>
|
||||
|
@ -49,16 +49,17 @@
|
|||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.social-networking</groupId>
|
||||
<artifactId>social-service-model</artifactId>
|
||||
<version>[1.2.0-SNAPSHOT, 2.0.0)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.socialnetworking</groupId>
|
||||
<artifactId>social-data-indexing-common</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>social-networking-library</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.elasticsearch</groupId>
|
||||
<artifactId>elasticsearch</artifactId>
|
||||
|
@ -76,26 +77,13 @@
|
|||
<version>1.0.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.netflix.astyanax</groupId>
|
||||
<artifactId>astyanax-core</artifactId>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>log4j-over-slf4j</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.astyanax</groupId>
|
||||
<artifactId>astyanax-thrift</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.astyanax</groupId>
|
||||
<artifactId>astyanax-cassandra</artifactId>
|
||||
<scope>provided</scope>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-mapper-asl</artifactId>
|
||||
<version>1.5.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.resources.discovery</groupId>
|
||||
|
@ -133,8 +121,8 @@
|
|||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package org.gcube.socialnetworking.social_data_search_client;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.portal.databook.shared.EnhancedFeed;
|
||||
import org.gcube.social_networking.socialnetworking.model.shared.EnhancedPost;
|
||||
import org.gcube.socialnetworking.social_data_indexing_common.utils.SearchableFields;
|
||||
|
||||
/**
|
||||
|
@ -13,28 +13,28 @@ import org.gcube.socialnetworking.social_data_indexing_common.utils.SearchableFi
|
|||
public interface ElasticSearchClient {
|
||||
|
||||
/**
|
||||
* Given a query, the method find matching enhanced feeds into the elasticsearch index and return
|
||||
* Given a query, the method find matching enhanced post into the elasticsearch index and return
|
||||
* at most <b>quantity</b> hits starting from <b>from</b>. A multimatch query is performed against all
|
||||
* searchable fields.
|
||||
* @param query the query to match
|
||||
* @param vreIDS specifies the vre(s) to which the returning feeds must belong
|
||||
* @param vreIDS specifies the vre(s) to which the returning posts must belong
|
||||
* @param from start hits index
|
||||
* @param quantity max number of hits to return starting from <b>from</b>
|
||||
* @return A list of matching enhanced feeds or nothing
|
||||
* @return A list of matching enhanced posts or nothing
|
||||
*/
|
||||
List<EnhancedFeed> search(String query, Set<String> vreIDS, int from, int quantity);
|
||||
List<EnhancedPost> search(String query, Set<String> vreIDS, int from, int quantity);
|
||||
|
||||
/**
|
||||
* Given a query, the method find matching enhanced feeds into the elasticsearch index and return
|
||||
* Given a query, the method find matching enhanced posts into the elasticsearch index and return
|
||||
* at most <b>quantity</b> hits starting from <b>from</b>. The query is performed against one of the searchable fields.
|
||||
* @param query the query to match
|
||||
* @param vreIDS specifies the vre(s) to which the returning feeds must belong
|
||||
* @param vreIDS specifies the vre(s) to which the returning posts must belong
|
||||
* @param from start hits index
|
||||
* @param quantity max number of hits to return starting from <b>from</b>
|
||||
* @param field the field against which the query is performed
|
||||
* @return A list of matching enhanced feeds or nothing
|
||||
* @return A list of matching enhanced posts or nothing
|
||||
*/
|
||||
List<EnhancedFeed> searchInField(String query, Set<String> vreIDS, int from, int quantity, SearchableFields field);
|
||||
List<EnhancedPost> searchInField(String query, Set<String> vreIDS, int from, int quantity, SearchableFields field);
|
||||
|
||||
/**
|
||||
* Delete from the index a document with id docID.
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.elasticsearch.index.query.MultiMatchQueryBuilder.Type;
|
|||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.index.query.TermsQueryBuilder;
|
||||
import org.elasticsearch.search.SearchHit;
|
||||
import org.gcube.portal.databook.shared.EnhancedFeed;
|
||||
import org.gcube.social_networking.socialnetworking.model.shared.EnhancedPost;
|
||||
import org.gcube.socialnetworking.social_data_indexing_common.utils.ElasticSearchRunningCluster;
|
||||
import org.gcube.socialnetworking.social_data_indexing_common.utils.IndexFields;
|
||||
import org.gcube.socialnetworking.social_data_indexing_common.utils.SearchableFields;
|
||||
|
@ -94,9 +94,9 @@ public class ElasticSearchClientImpl implements ElasticSearchClient{
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<EnhancedFeed> search(String query, Set<String> vreIDS, int from, int quantity){
|
||||
public List<EnhancedPost> search(String query, Set<String> vreIDS, int from, int quantity){
|
||||
|
||||
List<EnhancedFeed> toReturn = new ArrayList<>();
|
||||
List<EnhancedPost> toReturn = new ArrayList<>();
|
||||
|
||||
if(from < 0 || quantity <= 0 || vreIDS.isEmpty())
|
||||
return toReturn;
|
||||
|
@ -146,11 +146,11 @@ public class ElasticSearchClientImpl implements ElasticSearchClient{
|
|||
|
||||
// rebuild objects
|
||||
for (SearchHit hit : results) {
|
||||
EnhancedFeed enhFeed;
|
||||
EnhancedPost enhPost;
|
||||
try {
|
||||
|
||||
enhFeed = mapper.readValue(hit.getSourceAsString(), EnhancedFeed.class);
|
||||
toReturn.add(enhFeed);
|
||||
enhPost = mapper.readValue(hit.getSourceAsString(), EnhancedPost.class);
|
||||
toReturn.add(enhPost);
|
||||
|
||||
} catch (IOException e) {
|
||||
logger.error(e.toString());
|
||||
|
@ -162,10 +162,10 @@ public class ElasticSearchClientImpl implements ElasticSearchClient{
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<EnhancedFeed> searchInField(String query, Set<String> vreIDS,
|
||||
public List<EnhancedPost> searchInField(String query, Set<String> vreIDS,
|
||||
int from, int quantity, SearchableFields field) {
|
||||
|
||||
List<EnhancedFeed> toReturn = new ArrayList<>();
|
||||
List<EnhancedPost> toReturn = new ArrayList<>();
|
||||
|
||||
if(from < 0 || quantity <= 0 || field == null || vreIDS.isEmpty())
|
||||
return toReturn;
|
||||
|
@ -207,11 +207,11 @@ public class ElasticSearchClientImpl implements ElasticSearchClient{
|
|||
|
||||
// rebuild objects
|
||||
for (SearchHit hit : results) {
|
||||
EnhancedFeed enhFeed;
|
||||
EnhancedPost enhPost;
|
||||
try {
|
||||
|
||||
enhFeed = mapper.readValue(hit.getSourceAsString(), EnhancedFeed.class);
|
||||
toReturn.add(enhFeed);
|
||||
enhPost = mapper.readValue(hit.getSourceAsString(), EnhancedPost.class);
|
||||
toReturn.add(enhPost);
|
||||
|
||||
} catch (IOException e) {
|
||||
logger.error(e.toString());
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.portal.databook.shared.EnhancedFeed;
|
||||
import org.gcube.social_networking.socialnetworking.model.shared.EnhancedPost;
|
||||
import org.gcube.socialnetworking.social_data_indexing_common.utils.SearchableFields;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -34,7 +34,7 @@ public class Tests
|
|||
|
||||
Set<String> set = new HashSet<String>();
|
||||
set.add("/gcube/devNext/NextNext");
|
||||
List<EnhancedFeed> results = el.searchInField("Costantino Perciante", set, 0, 10, SearchableFields.POST_AUTHOR);
|
||||
List<EnhancedPost> results = el.searchInField("Costantino Perciante", set, 0, 10, SearchableFields.POST_AUTHOR);
|
||||
|
||||
logger.debug("First result is " + results);
|
||||
|
||||
|
|
Loading…
Reference in New Issue