Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
<parent>
<artifactId>lutece-global-pom</artifactId>
<groupId>fr.paris.lutece.tools</groupId>
<version>5.2.0</version>
<version>8.0.0-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
<groupId>fr.paris.lutece.plugins</groupId>
<artifactId>library-elastic</artifactId>
<version>1.1.3-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
<name>Lutece elastic library</name>
<packaging>jar</packaging>
<description>elastic client library</description>
Expand All @@ -18,15 +18,15 @@
<repository>
<id>luteceSnapshot</id>
<name>luteceSnapshot</name>
<url>http://dev.lutece.paris.fr/snapshot_repository</url>
<url>https://dev.lutece.paris.fr/snapshot_repository</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>lutece</id>
<name>luteceRepository</name>
<url>http://dev.lutece.paris.fr/maven_repository</url>
<url>https://dev.lutece.paris.fr/maven_repository</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
Expand All @@ -37,21 +37,21 @@
<dependency>
<groupId>fr.paris.lutece.plugins</groupId>
<artifactId>library-httpaccess</artifactId>
<version>[2.6.0,)</version>
<version>[4.0.0-SNAPSHOT,)</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.15.3</version>
</dependency>
<dependency>
<groupId>fr.paris.lutece.plugins</groupId>
<artifactId>library-lutece-unit-testing</artifactId>
<type>jar</type>
<scope>test</scope>
</dependency>
</dependencies>

<properties>
<jiraProjectName>LIBELASTIC</jiraProjectName>
<jiraComponentId>10158</jiraComponentId>
</properties>

<scm>
<connection>scm:git:https://github.com/lutece-platform/lutece-elk-library-elastic.git</connection>
<developerConnection>scm:git:https://github.com/lutece-platform/lutece-elk-library-elastic.git</developerConnection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected final ObjectNode getNodeAction( JsonNodeFactory factory )
{
objId.put( Constants.ELK_ID, _strId );
}
content.put( _strAction, objId );
content.replace( _strAction, objId );

return content;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.collections.CollectionUtils;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
Expand Down Expand Up @@ -150,7 +148,7 @@ protected ObjectNode getNodeContent( JsonNodeFactory factory )
{
ObjectNode content = new ObjectNode( factory );

if ( CollectionUtils.isNotEmpty( _listMust ) )
if ( _listMust != null && !_listMust.isEmpty( ) )
{
JsonNode must;
if ( _listMust.size( ) == 1 )
Expand All @@ -168,7 +166,7 @@ protected ObjectNode getNodeContent( JsonNodeFactory factory )
content.set( "must", must );
}

if ( CollectionUtils.isNotEmpty( _listFilter ) )
if ( _listFilter != null && !_listFilter.isEmpty( ) )
{
JsonNode filter;
if ( _listFilter.size( ) == 1 )
Expand All @@ -186,7 +184,7 @@ protected ObjectNode getNodeContent( JsonNodeFactory factory )
content.set( "filter", filter );
}

if ( CollectionUtils.isNotEmpty( _listShould ) )
if ( _listShould != null && !_listShould.isEmpty( ) )
{
JsonNode should;
if ( _listShould.size( ) == 1 )
Expand All @@ -204,7 +202,7 @@ protected ObjectNode getNodeContent( JsonNodeFactory factory )
content.set( "should", should );
}

if ( CollectionUtils.isNotEmpty( _listMustNot ) )
if ( _listMustNot != null && !_listMustNot.isEmpty( ) )
{
JsonNode mustNot;
if ( _listMustNot.size( ) == 1 )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,20 @@
*/
package fr.paris.lutece.plugins.libraryelastic.util;

import fr.paris.lutece.portal.service.util.AppLogService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
* ElasticClientException
*/
public class ElasticClientException extends Exception
{
private static final String LOGGER = "lutece.application";
private static final Logger _logger = LogManager.getLogger( LOGGER );

public ElasticClientException( String strMessage, Throwable exception )
{
super( strMessage, exception );
AppLogService.error( strMessage, exception );
_logger.error( strMessage, exception );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/
package fr.paris.lutece.plugins.libraryelastic.business.search;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/
package fr.paris.lutece.plugins.libraryelastic.business.suggest;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@
import java.util.Map;

import org.apache.commons.io.IOUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runners.model.InitializationError;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;

import fr.paris.lutece.plugins.libraryelastic.business.search.BoolQuery;
import fr.paris.lutece.plugins.libraryelastic.business.search.MatchLeaf;
Expand All @@ -53,31 +55,27 @@
/**
* Elastic Test
*/
@TestInstance( Lifecycle.PER_CLASS )
public class ElasticTest
{
private static final String INDEX = "testlibraryindex";
private static final String TYPE = "mydoc";
private Elastic _elastic;

/**
* @throws InitializationError
* @throws IOException
*/
public ElasticTest( ) throws InitializationError, IOException
@BeforeAll
public void setUp( ) throws Exception
{
super( );
AppPropertiesService.load( getClass( ).getResourceAsStream( "/elastic.properties" ) );
this._elastic = new Elastic( AppPropertiesService.getProperty( "elastic.url" ) );
}

@Before
@BeforeEach
public void createIndex( ) throws IOException, ElasticClientException
{
String strJsonMappings = IOUtils.toString( getClass( ).getResourceAsStream( "/mapping.json" ), StandardCharsets.UTF_8 );
_elastic.createMappings( INDEX, strJsonMappings );
}

@After
@AfterEach
public void deleteIndex( ) throws ElasticClientException
{
_elastic.deleteIndex( INDEX );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
*/
public final class AppPropertiesService
{
private final static Properties _props = new Properties( );
private static final Properties _props = new Properties( );

/**
* Private constructor
Expand Down
20 changes: 0 additions & 20 deletions src/test/resources/log4j.xml

This file was deleted.

23 changes: 10 additions & 13 deletions src/test/resources/mapping.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
{
"mappings": {
"mydoc": {
"dynamic": true,
"properties": {
"message": {
"type": "string"
},
"not_message": {
"index": "not_analyzed",
"type": "string"
},
"suggest": {
"type": "completion"
}
"dynamic": true,
"properties": {
"message": {
"type": "text"
},
"not_message": {
"type": "keyword"
},
"suggest": {
"type": "completion"
}
}
}
Expand Down